http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/releasenote.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/releasenote.md b/doc/source/cn/releasenote.md deleted file mode 100644 index 02aa8c8..0000000 --- a/doc/source/cn/releasenote.md +++ /dev/null @@ -1,353 +0,0 @@ ---- -title: Release Note -type: releasenote -layout: post ---- - -# Release Note - -## v0.17 ------ - -* `feature` `Android/iOS` Support `writing direction style:direction=rtl`([#782](https://github.com/apache/incubator-weex/pull/782)[#886](https://github.com/apache/incubator-weex/pull/886)) -* `feature` `Android/iOS` Support scroll start and scroll end event on scroller and list ([#858](https://github.com/apache/incubator-weex/pull/858)[856](https://github.com/apache/incubator-weex/pull/856)) -* `feature` `iOS` support text max-width ï¼[#834](https://github.com/apache/incubator-weex/pull/834)ï¼ -* `feature` `Android` CSS Transiton Animation Supported component ([#851](https://github.com/apache/incubator-weex/pull/851)) -* `feature` `Android` New `local` module ([#781](https://github.com/apache/incubator-weex/pull/781)) -* `feature` `Android` Support ripple background on Android 5.0 and higher ([#792](https://github.com/apache/incubator-weex/pull/792)) -* `feature` `Android` Support multi language on dialog ([#831](https://github.com/apache/incubator-weex/pull/831)) -* `feature` `H5` Support lazyload and appear watcher when body height set to 100% ([#827](https://github.com/apache/incubator-weex/pull/827)). -* `feature` `H5` Add try catch for storage accessing incase user disabled the related function in a browser ([#827](https://github.com/apache/incubator-weex/pull/827)). -* `feature` `H5` image support css sprite (sprite-src, sprite-position, sprite-width) ([#827](https://github.com/apache/incubator-weex/pull/827)). -* `feature` `JSFM` Support batch update styles and attributes in Vue.js ([#819](https://github.com/apache/incubator-weex/pull/819) [#7046](https://github.com/vuejs/vue/pull/7046)) -* `feature` `JSFM` Stop trimming CSS units in richtext component. ([#6927](https://github.com/vuejs/vue/pull/6927)) -* `feature` `JSFM` Stop rethrow the captured error on Weex platform. ([#7024](https://github.com/vuejs/vue/pull/7024)) -* `feature` `JSFM` Upgrade weex-vue-framework to 2.5.3 ([release nodes](https://github.com/vuejs/vue/releases/tag/v2.5.3)) -* `feature` `JSFM` Adjust the behavior of `nextTick` to improve compatibility. -* `bugfix` `iOS` bugfix boxshadow render abnormal ï¼[#791](https://github.com/apache/incubator-weex/pull/791)ï¼ -* `bugfix` `iOS` bugfix timer exposed on JSContxt ï¼[#839](https://github.com/apache/incubator-weex/pull/839)ï¼ -* `bugfix` `iOS` fix iOS8 scrollviewâs assign delegate crash ï¼[#838](https://github.com/apache/incubator-weex/pull/838)ï¼ -* `bugfix` `iOS` fix setViewportï¼sometimes doesnât workï¼[#843](https://github.com/apache/incubator-weex/pull/843)ï¼ -* `bugfix` `iOS` fix addEvent lead to generate a new view while it as been recycled ï¼[#837](https://github.com/apache/incubator-weex/pull/837)ï¼ -* `bugfix` `iOS` fix about setting nan frame crash ï¼[#853](https://github.com/apache/incubator-weex/pull/853)ï¼ -* `bugfix` `iOS` disable tableview estimation row or section height which make list component behavior abnormal ï¼[#867](https://github.com/apache/incubator-weex/pull/867)ï¼ -* `bugfix` `Android` Fix that moveElement doesnât work when parent is not a list ([#805](https://github.com/apache/incubator-weex/pull/805)) -* `bugfix` `Android` Fix flicker caused by coexistence of box-shadow and border-radius (#[780](https://github.com/apache/incubator-weex/pull/780)) -* `bugfix` `Android` Fix android new Date() cannot get accuracy time ([#753](https://github.com/apache/incubator-weex/pull/753)) -* `bugfix` `H5` Fix scroll event listenning and scrollToElement on chrome for the latest version ([#827](https://github.com/apache/incubator-weex/pull/827)). - -## v0.16 ------ -* + support 3d rotate ([#532](https://github.com/apache/incubator-weex/pull/532) [#418](https://github.com/apache/incubator-weex/pull/418)) -* + new feature support perspective function in transform ([#551](https://github.com/apache/incubator-weex/pull/551)[#532](https://github.com/apache/incubator-weex/pull/532)) -* + new feature support save image to photo album ([547](https://github.com/apache/incubator-weex/pull/547) [575](https://github.com/apache/incubator-weex/pull/575) [544](https://github.com/apache/incubator-weex/pull/544)) -* + support `image.save` ([#575](https://github.com/apache/incubator-weex/pull/575)). -* + optimize event binding and support mobile firefox, and also fix a lot of other things ([#606](https://github.com/apache/incubator-weex/pull/606)). -* + Support js service in Rax DSL. -* + Partial support of sending `ArrayBuffer` between js and native. -* + Add basic support of `<recycle-list>`, both in Vue and Rax DSL. -* + Support saving image to photo alubm in `image` [#547](https://github.com/apache/incubator-weex/pull/547) -* + Support perspective features [#551](https://github.com/apache/incubator-weex/pull/551) -* + New interface to performance tracing [#586](https://github.com/apache/incubator-weex/pull/586) -* + Add the ability of FlatGUI, it can reduce the view hierarchy in `cell` [#643](https://github.com/apache/incubator-weex/pull/643) -* + Support the `box-shadow` style for Android 4.3 and higher [#685](https://github.com/apache/incubator-weex/pull/685) -* + Support float interval/delay in timer [#699](https://github.com/apache/incubator-weex/pull/699) -* + New `recycle-list` compoent with hight performance and low memory cost [#726](https://github.com/apache/incubator-weex/pull/726) -* * remove dependency about socketRocket dependency in iOS. -* * fix coretext crash in iOS. -* * fix toast view still pop while the page was destroyed in iOS. -* * separate weex-vue-render into two parts: render core and plugins ([#533](https://github.com/apache/incubator-weex/pull/533)). -* * Fix Jni crash due to emoji [#574](https://github.com/apache/incubator-weex/pull/574) -* * Fix the lost refresh header of `list` in viewpager [#601](https://github.com/apache/incubator-weex/pull/601) -* * Fix draw iconfont fail when first download iconfont [#625](https://github.com/apache/incubator-weex/pull/625) -* * Fix the problem of 'text-overflow:clip' [#718](https://github.com/apache/incubator-weex/pull/718) -* * Fix android new Date() cannot get accuracy time [#753](https://github.com/apache/incubator-weex/pull/753) - -## v0.15 ------- -* + support fast click and hairlines border [#507](https://github.com/apache/incubator-weex/pull/507). -* + Add `weex.supports` api for feature detections. [#6053](https://github.com/vuejs/vue/pull/6053) -* + Change default image quality to `WXImageQuality.AUTO` [#478](https://github.com/apache/incubator-weex/pull/478) -* + Support the `scroll` event on horizontal scroller[#494](https://github.com/apache/incubator-weex/pull/494) -* * Fix the console API to adapt JSC on Android. [#470](https://github.com/apache/incubator-weex/pull/470) -* * Fix invalid call scrollToElement when has not option param [#491](https://github.com/apache/incubator-weex/pull/491) -* * Fix the lines of `text` cannot be reset [#493](https://github.com/apache/incubator-weex/pull/493) -* * Fix invalid init index on `slider` [#510](https://github.com/apache/incubator-weex/pull/510) -* * Fix Memory optimization for `list` [#512](https://github.com/apache/incubator-weex/pull/512) - -## v0.14 ------- -* + support `waterfall` component ([#438](https://github.com/apache/incubator-weex/pull/438)). -* + support pseudo-class ([#474](https://github.com/apache/incubator-weex/pull/474)). -* + Support component method in Vue DSL. ([proposal](https://github.com/alibaba/weex/issues/969)) -* + Support returning value synchronously for module methods. ([proposal](https://github.com/alibaba/weex/issues/1677)) -* + Support drag-drop on `list` [#416](https://github.com/apache/incubator-weex/pull/416) -* + Support rotateX and rotateY, optimize animation as well [#418](https://github.com/apache/incubator-weex/pull/418) -* * Fix wrong vertical offset in scroll event on `waterfall` [#424](https://github.com/apache/incubator-weex/pull/424) -* * Fix `clearTimeout` and `clearInterval` doesn't work when funId is greater than 127 [#439](https://github.com/apache/incubator-weex/pull/439) - -## v0.13.0 ------- -### Notable Changes -* Slider implemention is refactored [Pull Request#414](https://github.com/apache/incubator-weex/pull/414) -* Improve integration test. We are working with macaca team, to write better test code.[Pull Request#411](https://github.com/apache/incubator-weex/pull/411) [Pull Request#397](https://github.com/apache/incubator-weex/pull/397) [Pull Request#402](https://github.com/apache/incubator-weex/pull/402) [Pull Request#413](https://github.com/apache/incubator-weex/pull/413) [Pull Request#390](https://github.com/apache/incubator-weex/pull/390) [Pull Request#346](https://github.com/apache/incubator-weex/pull/346) [Pull Request#319](https://github.com/apache/incubator-weex/pull/319) [Pull Request#304](https://github.com/apache/incubator-weex/pull/304) [Pull Request#295](https://github.com/apache/incubator-weex/pull/295) -* `scroller` now has `pagingEnabled` attribute, which can enable `paging` feature in native [Pull Request#393](https://github.com/apache/incubator-weex/pull/393) -* New 'prerender' mechanism, which will support rendering a page in background. [Pull Request#343](https://github.com/apache/incubator-weex/pull/343) Pull Request#342](https://github.com/apache/incubator-weex/pull/342) -* Fix `line-height` feature in iOS. [Pull Request#377](https://github.com/apache/incubator-weex/pull/377) [Pull Request#305](https://github.com/apache/incubator-weex/pull/305) -* Add `needLayout` option in animation module operation after animation finished [Pull Request#337](https://github.com/apache/incubator-weex/pull/337) [Pull Request#336](https://github.com/apache/incubator-weex/pull/336) -* `list` component has new type of event for `sticky` feature [Pull Request#332](https://github.com/apache/incubator-weex/pull/332) -* Support bota and atob [Pull Request#315](https://github.com/apache/incubator-weex/pull/315) -* Fix mixing background-color and border-color(rgba) in android [Pull Request#359](https://github.com/apache/incubator-weex/pull/359) - - -Beside these, lots of crashes and bugs are fixed.[Pull Request#441](https://github.com/apache/incubator-weex/pull/441) [Pull Request#413](https://github.com/apache/incubator-weex/pull/413) [Pull Request#403](https://github.com/apache/incubator-weex/pull/403) [Pull Request#373](https://github.com/apache/incubator-weex/pull/373) - -## v0.12.0 ( First Offical Release) ---------- -- C++ timer by lycool -Discussed in https://lists.apache.org/thread.html/567c9b19d68ccf3e0d24c1467298ebcd4316ffa524c557a34c6c087f@%3Cdev.weex.apache.org%3E -relate pull requests:[apache/incubator-weex/pull/228|https://github.com/apache/incubator-weex/pull/228], [apache/incubator-weex/pull/232|https://github.com/apache/incubator-weex/pull/232], [apache/incubator-weex/pull/221|https://github.com/apache/incubator-weex/pull/221] - -- Add scroller/list scroll event in html5 render -android&iOS already have this feature in v0.11 -https://github.com/apache/incubator-weex/commit/f50fba8647c8bb6ac522b1a4569a2a2269da1953 - -- Enhance accessibility, new `aria-label` & `role` support -[apache/incubator-weex/pull/149|https://github.com/apache/incubator-weex/pull/149] - -- Native input/textarea enhancement by kfeagle & misakuo -support `number` data type; support soft keyboard event - -- Picker module enhancement -More picker options to customize picker dialog style(background color etc.). Related pull requests: [apache/incubator-weex/pull/234|https://github.com/apache/incubator-weex/pull/234], [apache/incubator-weex/pull/233|https://github.com/apache/incubator-weex/pull/233] - -- Android DOM module refactor -Seperate module code by action, increasing the maintainability. -[apache/incubator-weex/pull/104|https://github.com/apache/incubator-weex/pull/104] - -## v0.10.0 ------- -- New Feature - - Support Vue.js - The Vue.js 2.1.8 ([runtime-only build](https://vuejs.org/v2/guide/installation.html#Standalone-vs-Runtime-only-Build)) is in WeexSDK now. You can use Vue.js to build native app by WeexSDK 0.10.0. - We reused the original native render engine and developed a new renderer ([weex-vue-render](https://www.npmjs.com/package/weex-vue-render)) for the web platform, which is based on Vue 2.0. - The former front-end framework (commonly known as `.we`), which is inspired by Vue 1.0, is deprecated. Although it still works well in this release, we suggest to migrate it to Vue 2.0. - - SDK - - New CSS support - - [text `font-weight`](https://weex-project.io/references/text-style.html) - `font-weight` can set to [`normal`|`bold`] or 100-900. - - gradient - like CSS3, now you can use gradient in Weex. For example: - - ``` css - background-image: linear-gradient(to right, blue, white); - ``` - ![img_1695](https://cloud.githubusercontent.com/assets/115201/23015955/ba075876-f46f-11e6-9d88-2ca3096551b9.jpeg) - [Read more about gradient](https://weex-project.io/references/common-style.html). - - Pseudo class - Currently, Weex supports 4 pseudo classes:`active`, `focus`, `disabled`, `enabled`. - - New BroadcastChannel API - Developers can use `BroadcastChannel` API to implement inter-instance communication. - - ``` js - const Stack = new BroadcastChannel('Avengers') - Stack.onmessage = function (event) { - console.log(event.data) // in this case, it's "Hulk Smash !!!" - } - - // in another instance - const Hulk = new BroadcastChannel('Avengers') - Hulk.postMessage("Hulk Smash !!!") - ``` - - Image's `onload` event add [`naturalHeight` and `naturalWidthimage`](https://weex-project.io/references/components/image.html) to get the original size of image file. - - Websocket Support - WebSockets is an advanced technology that makes it possible to open an interactive communication session between the user's h5/iOS/android and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply. - [Read more about Weex's websocket.](https://weex-project.io/cn/references/modules/websocket.html) - - Support synchronous method call - Both module and component method can defined synchronous method exposed to JS runtime now. Means native will invoke these method in JS thread directly. - - Support `viewport` configuration - Similar to [W3C specification](https://drafts.csswg.org/css-device-adapt/#viewport-meta), Weex support set define `viewport` in script tag: - - ``` html - <script type="config"> - { - "viewport": { - "width": "device-width" - } - } - </script> - ``` - - Tools - - [Devtools](https://github.com/weexteam/weex-devtool) - - Support Vue 2.0 debugging. - - Add network switch for network inspector. - - Make application capable to decide which bundle is 'un-debuggable', which means page's source code is unreadable in debug mode. - - [Weexpack](https://github.com/weexteam/weex-pack) - - Has full set of commands for developers to setup android/ios application with his .we/.vue files. - - Developers could easily pack/install his application with simple command. - - Has full set of commands for developers to manage weex plugins, including create plugin template, add plugin to his project etc. - - [Plugin market](http://market.weex-project.io) was formally used for developers to publish/download weex plugins. - - -## v0.9.4 ------- -- New features - - SDK - - New API to get Component's size and position: - Now you can get these data through `getComponentRect`: - ``` javascript - var dom = require('@weex-module/dom'); - dom.getComponentRect(this.$el('comp_id'), function(data){ - if(data.result) - console.log(data); - }); - ``` - The `data` callback parameter contains a `result` to tell if operation is success. And `size` tell you the true data(`bottom`/`top`/`left`/`right`/`width`/`height`) of component. - - A brand new `picker` module. We have 'single-picker','date-picker' and 'time-picker' currently, and more common pickers are on the way. - ![img_1282](https://cloud.githubusercontent.com/assets/115201/21414801/e6341b36-c83d-11e6-9e5a-3acdabb592ee.png) - There are two ways to use `picker` - - Use `picker` module directly: - ``` javascript - var picker = require('@weex-module/picker'); - var self = this; - picker.pickDate({ - 'value':'2016-11-28', - 'max':'2029-11-28', - 'min':'2015-11-28' - },function (ret) { - var result = ret.result; - if(result == 'success') - { - self.value = ret.data; - } - }); - ``` - - `input` component also add 'date' and 'time`type to work with`picker` module internally: - ``` html - <input - type="date" - placeholder="select date" - class="input" - autofocus="false" - value="" - onchange="onchange" - max = "2029-11-28" - min = "2015-11-28" - ></input> - ``` - - Support animation with `width` and `height` property. - - Support use empty value to reset css property to default value. - - Components can expose methods too, like modules do. Developers use the same way as create module method to achieve that. - - Add `blur` and `focus` method to manually control `input` component to lose or get focus. - - Support relative URL, which will resolve real URL by bundle's URL. - - Core javascript framework's unit test coverage is 100% now. we'll pay more attention to quality. - - DevTool - - Support to check the node hierarchy in [weex-devtool-extension](https://github.com/weexteam/weex-devtool-extension) and highlight the node if it exceeds an specified level. - - Support different refresh mode in devtools to reload the page or SDK automatically when source file updated. - - Improve quality in [weex-devtools-android](https://github.com/weexteam/weex-devtools-android) module - - Remove explicit dependency on okhttp and okhttp3 by reflection and proxy - - Improve demo application with less and refactored code - - Fix some crash caused by class up cast - - Fix reflection crash caused by complier optimization - - Fix "network on main thread" and stop screencast when disconnect - - Add [weex-analyzer-android](https://github.com/weexteam/weex-analyzer-android) and [weex-analyzer-ios](https://github.com/weexteam/weex-analyzer-ios) which support the following on device directly: - - Inspect FPS/CPU/memory - - Inspect storage - - Display log information - - 3D viewer of the weex page - - Javascript error prompt - - -## v0.8.0 ------- - -- New Features - - Add [globalEvent module](https://github.com/alibaba/weex/blob/doc/doc/modules/globalevent.md) - - Support `width/height` animation in transition - - Refactor the default js framework code, hide almost all the private APIs #777 - - iOS 10 compatibility -- Performance - - Support `callAddElement` low-level API to make rendering faster - - Improve SDK initialization performance, for minimise invoke thread impact. - - Use native `Set` polyfill to fix iOS7 memory leak - - Use `setProperty` replace reflection for better performance - - Add `static` directive in default js framework to avoid unnecessary data-binding and take down the memory use -- Tools - - Add [weex-pack](https://github.com/weexteam/weex-pack), our next generation of engineering development kits. It allows developers to create weex projects with simple commands and run the project on different development platforms. - - Add [weex-devtool-extension](https://github.com/weexteam/weex-devtool-extension), a extension for Weex devtool to improve your debug experienceï¼which equivalent an element tag for debugger page. - - Move devtool to separate [iOS](https://github.com/weexteam/weex-devtool-iOS) and [Android](https://github.com/weexteam/weex_devtools_android) repos. - - Add "screencast" which enable the screen of the device(or monitor) to appear on the "Inspector" page; - - Add "remote control" function, in Android user could control remote device(or monitor) when he moves mouse on screencast; - - Add "select element" function which enable the user to find the exact node in "Elements" inspector Tab when he click the mouse on screencast; - - Add "vdom inspector", so user can choose to see the details of native dom or vdom in "Elements" Tab at his preference; - - Adjust interfaces with weex SDK to support "callAddElement"; - - -## v0.7.0 ------- -- New Features - - [Timer Module](https://github.com/alibaba/weex/blob/doc/doc/modules/timer.md) - - [Storage Module](https://github.com/alibaba/weex/blob/dev/doc/modules/storage.md) - - Unify the `image` component's error page when src is invalid - - Unify the `border`,`padding`,`background-color` style - - Horizontal-scroller support `scrollto` api - - Fix the issue that component with `position:fixed` style can not be closed - - Module callback support `object` params - - Slider suppport `setIndex` api -- Performance - - Use `callNative` signal to stop JSFM render after instance been destroyed - - Lazily initialize JSFM When device is in low-memory status, improve SDK stability -- [Tools](http://alibaba.github.io/weex/doc/tools/devtools.html) - - Support debugging weex(.we) and react(.jsx) source - - Support apps debugging on the same device - - Support "watch" feature - - Solve the dependency on Debugger, user could start "Inspector" first or "Debugger" at will - - Add "refresh" function in sdk, user could inspect new file by scanning its QR code in playground; - - Android/ios inspect module split from weex sdk, and will deliver in separate repo in future; support inspect in windows system - -## v0.6.1 ------- -- New Features - 1. [iOS has been open sourced](https://github.com/alibaba/weex/tree/dev/ios) - 2. [Lifecycle Page Event](https://github.com/alibaba/weex/blob/v0.6.1/doc/references/common-event.md#page-event): viewappear, viewdisappear - 3. [fetch](https://github.com/alibaba/weex/blob/v0.6.1/doc/modules/stream.md#fetchoptions-callbackprogresscallback) - 4. [line-height](https://github.com/alibaba/weex/blob/v0.6.1/doc/components/text.md#styles) - 5. [list component](https://github.com/alibaba/weex/blob/v0.6.1/doc/components/list.md) - - support sticky header - - support scrollToElement API - - support nested horizontal scroller - - support cell children nodes event: appear/disappear - 6. [Gesture](https://github.com/alibaba/weex/blob/v0.6.1/doc/references/gesture.md): panstart/panmove/panend, swipe, longpress - 7. Improve Android text compatibility -- Performance - 1. iOS, iPhone 5c, rendering frame rate ascends from 45FPS to 52FPS - 2. Android, Redmi Note 1, loading time of the first screen descends from 602ms to 480ms - 3. Improve Android animation performance -- Tools - 1. [weex-toolkit](https://www.npmjs.com/package/weex-toolkit) supports require and generator - 2. Playground supports runtime performance viewer - 3. [Weex DevTools](https://github.com/alibaba/weex/blob/v0.6.1/doc/tools/devtools.md) - - <img src="https://img.alicdn.com/tps/TB1O.nwKFXXXXX8XpXXXXXXXXXX-1436-811.png" width="600"> - - -## v0.5.0 ------- - -### New Features -1. [TabBar](https://github.com/alibaba/weex/blob/dev/doc/components/wxc-tabbar.md) is a specialized component corresponding to the radio-style selection. -2. [NavPage](https://github.com/alibaba/weex/blob/dev/doc/components/wxc-navpage.md) contains a navbar at the top of the window and an embed content page. -3. [Activity Showcase](https://github.com/alibaba/weex/blob/dev/examples/showcase/new-fashion/index.we) is built by composing TabBar and NavPage. -4. [Web](https://github.com/alibaba/weex/blob/dev/doc/components/web.md) displays web content in the weex page. -5. [A](https://github.com/alibaba/weex/blob/dev/doc/components/a.md) defines a hyperlink to a page in the web. -6. `Text` supports style [text-overflow](https://github.com/alibaba/weex/blob/dev/doc/references/text-style.md#properties). -7. `Image` supports attribute [resize](https://github.com/alibaba/weex/blob/dev/doc/components/image.md#styles). -8. `List` supports [events `appear`, `disappear`, `loadmore`](https://github.com/alibaba/weex/blob/dev/doc/components/list.md#events) and [refresh](https://github.com/alibaba/weex/blob/dev/doc/components/list.md#child-components). -9. New Syntax - 1. [Inline event](https://github.com/alibaba/weex/blob/dev/doc/syntax/events.md#inline-handler) supports a expression of calling event handler in template. - 2. [Require Native Module](https://github.com/alibaba/weex/blob/dev/doc/modules#how-to-use) requires a native module by `require('@weex-module/moduleName')`. - 3. [Computed Property](https://github.com/alibaba/weex/blob/dev/doc/syntax/data-binding.md#computed-properties) supports complicated logic in data bindings. - 4. [New Repeat Syntax](https://github.com/alibaba/weex/blob/dev/doc/syntax/display-logic.md#a-extension-of-repeat-syntax) is easy to access the key or value of repeated object. - - ------- \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/create-a-weex-project.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/create-a-weex-project.md b/doc/source/cn/v-0.10/advanced/create-a-weex-project.md deleted file mode 100644 index 780341b..0000000 --- a/doc/source/cn/v-0.10/advanced/create-a-weex-project.md +++ /dev/null @@ -1,271 +0,0 @@ ---- -title: å¦ä½å建ä¸ä¸ª Weex é¡¹ç® -type: advanced -order: 3 -has_chapter_content: true -version: 0.10 ---- - -# å¦ä½å建ä¸ä¸ª Weex é¡¹ç® - -对äºå端å¼åè æ¥è¯´å¼åä¸ä¸ª app æ¯ä¸å®¹æçï¼æ¢ç¶ Weex è½ä»¥ web çå¼åä½éªæ建é«æ§è½ãå¯æ©å±ç native åºç¨ï¼é£æ们æä¹å©ç¨ Weex ç®åé«æçå¼åä¸ä¸ª native åºç¨å¢ï¼Weex æ¿ä½ èèäºè¿ä»¶äºãå¨æ¬ç« ä¸ï¼æ们å°å¦ä¹ å¦ä½ä½¿ç¨ Weexpack å·¥å ·å¿«éçæä¸ä¸ªå ¨æ°ç Weex 项ç®ã - -æ ¹æ®ä½ çæä½ç³»ç»çä¸åï¼æ¥éª¤ä¹ç¥æå·®å¼ï¼å¦æä½ ä»æªæ¥è§¦è¿ native å¼åï¼è¯·æ ¢æ ¢æ¥ï¼éå°é®é¢éæ¶æ¥é [FAQ](../faq.md)ã - -é¦å ï¼ä¸è®ºä»»ä½å¹³å°ï¼æ们é½éè¦ node.js å Weexpackãå¨æ¬èä¸ï¼é»è®¤ä½ å·²ç»å®è£ å¥½äº node.js å npmï¼å¦æçé®ï¼å¯åèä¸ä¸ç« [å¦ä½å¨æ¬å°å¼å Weex 页é¢](../guide/develop-on-your-local-machine.html)ã - -Weexpack æ¯ Weex æ°ä¸ä»£çå·¥ç¨å¼åå¥ä»¶ï¼å®å 许å¼åè éè¿ç®åçå½ä»¤ï¼å建 weex å·¥ç¨é¡¹ç®ï¼å°é¡¹ç®è¿è¡å¨ä¸åçå¼åå¹³å°ä¸ãæªæ¥ï¼æ们èèä¼å°å ¶éæå¨ weex-toolkits ä¸ï¼ä½ç®åä»éè¦åç¬å®è£ ã好å¨å®è£ Weexpack é常ç®åï¼å¯ä»¥ç´æ¥ä½¿ç¨ npm å®è£ ï¼ - -```bash -npm install weexpack -g -``` - -æè ç¨ cnpmï¼ - -```bash -cnpm install weexpack -g -``` - -æ¥ä¸æ¥çæ¥éª¤ä¼æä¸äºå¤æååºå«ï¼æ ¹æ®å¼åå¹³å°çä¸åï¼æ们æä¾äºå¿«é导èªä¾¿äºé è¯»ï¼ - -- [iOS](#ios) -- [Android](#android) - -## iOS - -Mac æ¯å¯ä¸å¯ä»¥å¼å iOS åºç¨çå¹³å°ï¼å æ¤å建 iOS 项ç®åªæ¯æ macãå¯¹äº iOSï¼ä½ éè¦å®è£ [Xcode](https://developer.apple.com/xcode/) å [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) ã - -å®è£ Xcode æç®åçæ¹æ³æ¯å° [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12)ãXcode ä½ç§¯è¾å¤§ï¼ä¸è½½è¯·èå¿çå¾ ã - -å®è£ 好 Xcode åï¼ä½ éè¦è¿è¡ Xcodeï¼ä½¿ Xcode èªå¨å®è£ å¼åè å·¥å ·å确认使ç¨åè®®ã - -ä¹åä½ è¿éè¦å®è£ [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) ãCocoaPods æ¯ Xcode 项ç®çç±»åºç®¡çå·¥å ·ï¼å¯ä»¥ä½¿ç¨å¦ä¸å½ä»¤å®è£ ï¼ - -```bash -$ sudo gem install cocoapods -``` - -å¦ææ§è¡è¯¥å½ä»¤æ ååºï¼å¾å¯è½æ¯ gem source é®é¢ï¼ä½ å¯ä»¥åæ¢ä¸ºæ·å® gem sourceï¼ - -```bash -$ gem sources --remove https://rubygems.org/ -$ gem sources -a https://ruby.taobao.org/ -$ sudo gem install cocoapods -``` - -å¦æé®é¢ï¼å¯åè [CocoaPods å®æ¹ææ¡£](https://guides.cocoapods.org/using/getting-started.html) - -### åå»ºé¡¹ç® - -ç¶åï¼å°±å¯ä»¥ä½¿ç¨ weexpack å建 weex å·¥ç¨äºï¼ - -```bash -$ weexpack init appName -``` - -weexpack ä¼èªå¨æ°å»ºä»¥ appName å½åçç®å½ï¼å¹¶å°é¡¹ç®æ¨¡æ¿æåå°è¯¥ç®å½ã - -æç»å½¢æå¦ä¸ç®å½ç»æï¼ - -```bash --> /appName -. -|ââ .gitignore -|ââ README.md -|ââ package.json -|-- android.config.json -|-- ios.config.json -|ââ webpack.config.js -|ââ /src -| |ââ index.we -|ââ /html5 -| |ââ index.html -|ââ /ios -| |ââ /playground -| |ââ /sdk -| |ââ /WXDevtool -|ââ /android -| |ââ /playground -| |ââ /appframework -``` - -å ¶ä¸ï¼ - -- `webpack.config.js` æ¯ webpack é ç½®æ件ï¼ç¨äºçæ `.we` æ件ç JSBunlde -- `ios.config.json` æ¯ iOS 项ç®é ç½®æ件 -- `android.config.json` æ¯ Android 项ç®é ç½®æ件 -- `/src` ç®å½æ¾ç½® Weex é¡µé¢ -- `/html5` æ¯ H5 ç«¯å ¥å£æ件 -- `/ios` æ¾ç½® iOS é¡¹ç® -- `/android` æ¾ç½® Android é¡¹ç® - -ç´§æ¥çï¼è¿å ¥ç®å½ï¼å¹¶ä¸å®è£ ä¾èµï¼ - -```bash -$ cd appName && npm install -``` - -è³æ¤ï¼é¡¹ç®æ¨¡çå建å®æï¼æ¥ä¸æ¥æ们å¯ä»¥èªå®ä¹æ们ç APP ä¿¡æ¯å¹¶æå è¿è¡ã - -### è¿è¡ä¸æå - -å¦æä¸åæ£å¸¸ï¼ä½ å¯ä»¥ä½¿ç¨ weexpack æå æ模æå¨è¿è¡äºï¼ - -模æå¨è¿è¡ - -```bash -$ weexpack run ios -``` - -æ建 ipa å ï¼ - -```bash -$ weexpack build ios -``` - -æ建å çè¿ç¨ä¸ï¼å°ä¼æ示让æ¨è¾å ¥ CodeSignï¼è¯ä¹¦ï¼ãProfile(provisioning profile)ãAppIdï¼åªæè¾å ¥çå®çè¿äºä¿¡æ¯æè½æåæå ã å ¶ä½å¦AppNameï¼åå ¥å£ weex bundle æ件å¯ä»¥ç¼è¾é¡¹ç®ç®å½ä¸ç `ios.config.json` é ç½®ã æå®å æåä¹åï¼å¯ä»¥å¨ `/playground/build/ipa_build/` ç®å½ä¸è·å ipa æ件ã - -注ï¼è¯ä¹¦éè¦é¢å å®è£ å° keychain ä¸ï¼å¨ keychain ä¸ç¹å»å³é®è·åè¯ä¹¦ idï¼è¯ä¹¦å称ï¼ãprovisioning profile æ件ï¼\*mobileprovisionï¼éè¦è·å UUIDï¼è¿å ¥ç®å½å¯ä»¥çå° mobileprovision_UUID.sh æ件ï¼æ¤æ件å¯ä»¥è·åå° UUIDã - -mobileprovision_UUID.sh ç¨æ³å¦ä¸ï¼ - -```bash -$ ./mobileprovision_UUID.sh *mobileprovision -``` - -åæ°ï¼\*mobileprovisionï¼ä¸º provisioning profile æä»¶è·¯å¾ - -** 注ï¼run ä¸ build é¨åæ¶å pod çä¾èµå®è£ é®é¢ã** - -- é¦å è¦å®è£ cocoapods ï¼å ·ä½å®è£ æ¥éª¤å¯æ¥ç[è¿é](https://cocoapods.org/)ï¼å»ºè®®å®è£ 0.39.0 çæ¬ã -- 为äºå å¿« CLI æ§è¡é度ï¼weexpack å建çå·¥ç¨é»è®¤å®è£ äºéè¦çä¾èµåºãä½æ¯å½ä»¤æ§è¡ä¾ç¶ä¼æ´æ°éè¦å级çä¾èµåºã - - å¦æåºç°è¿ç§é误æ示 `unable to find a specification for 'WeexSDK'` è¿ç§é误ï¼è¯´æä½ æ¬å°æ²¡ææ´æ° cocoapods master ä»åºï¼è¿è¡ `pod repo update` ï¼æ¤æ¶è¿è¡ `pod search WeexSDK`ï¼ - - ![](https://img.alicdn.com/tps/TB1jLx4OFXXXXaoXFXXXXXXXXXX-212-33.png) - - 说æ master repo æ´æ°æåã以ä¸æ¯ä»¥ `WeexSDK` 为ä¾ï¼å ¶ä»åºç±»ä¼¼ã - - - å¦æåºç°è¿ç§é误 `error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.` è¿å ¥ playground ç®å½ï¼podfile æ件æå¨ç®å½ï¼ææ示æ§è¡ã - - æ´å¤ pod 使ç¨ç»è请移æ¥[cocoapods](https://cocoapods.org/) - -- mobileprovisionï¼åæ°ï¼\*mobileprovisionï¼ä¸º provisioning profile æ件路å¾ã - ----- - -## Android - -å¨ Mac å¹³å°å¼å Android é¦å éè¦ä¸è½½ [Android Studio](https://developer.android.com/studio/install.html)ï¼ä½ å¯è½éè¦ç¿»å¢æè½è®¿é®ï¼ã[Android Studio](https://developer.android.com/studio/install.html) 为æ们æä¾äº Android SDK å AVDï¼æ¨¡æå¨ï¼ä»¥ä¾¿æ们快éè¿è¡ Android 项ç®ã - -ä¸è½½å®æåè¿è¡ Android Studioï¼ä»»ææ°å»ºä¸ä¸ª Android 项ç®ï¼å¨ç¬¬äºæ¥ä¸éæ© **Android 5.1**ï¼ç¶åç¹å» next å®æ项ç®å建ï¼å¦å¾æç¤ºï¼ - -![android](https://gw.alicdn.com/tps/TB1VulhOFXXXXcPXFXXXXXXXXXX-828-686.png) - -å¾ Android Studio æå¼åï¼å¨é¡¶é¨èåæ éæ© Tools -> Android -> AVD Managerï¼å®è£ Android 模æå¨ï¼ - -![android](https://img.alicdn.com/tps/TB1CBdgOFXXXXXnXVXXXXXXXXXX-661-392.jpg) - -ä¹åï¼æå¼æ¨¡æå¨è¿è¡ Androidã - -**注æï¼** - -1. å¿ é¡»ä¿æ模æå¨è¿è¡ã -2. ä¿è¯ Android build-tool ççæ¬ä¸º 23.0ããå¯ä»¥å¨ Android Studio ç SDK Manager éæ¥çæ¯å¦å·²å®è£ è¿ä¸ªçæ¬ï¼å¦æ没æå¯éæ©å®è£ è¿ä¸çæ¬ãã - -### é ç½®ç¯å¢åé - -å 为 Android Studio å®è£ ç SDK ä¸ä¼èªå¨é ç½®ç¯å¢åéï¼ä½ èªå·±å®è£ ç SDK åæ ·ä¸ä¼ï¼ãæ以éè¦æ¨èªå·±æå¨é ç½® Android_HOME ç¯å¢åéå PATH - -å¦ææ¯ Android Studio å®è£ ç SDK å®è£ è·¯å¾å¯å·²å¨ SDK manager éæ¾å°ï¼æå¼ SDK manager çæ¹å¼è¯·åç §å¾2ï¼ - -Windows ä¸è¯·åç § [window ä¸å¦ä½è®¾ç½® ANDROID ç¯å¢åé](http://jingyan.baidu.com/article/09ea3ede1b4df6c0aede39ab.html) - -Linux/Mac ä¸åªéç¼è¾ `.bash_profile` å¢å PATH å³å¯ï¼ - -```bash -vim ~/.bash_profile -``` - -ç¶åæ·»å ä¸å代ç è¿å»ï¼è·¯å¾æ¿æ¢ä¸ºä½ ççå®è·¯å¾ï¼ - -```bash -export ANDROID_HOME=/xxx/Library/Android/sdk -export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools -``` - -ç¶åä¿åéåºï¼:wqï¼ãåæ§è¡ä¸åå½ä»¤ï¼ - -```bash -source ~/.bash_profile -``` - -### åå»ºé¡¹ç® - -ç¶åï¼å°±å¯ä»¥ä½¿ç¨ weexpack å建 weex å·¥ç¨äºï¼ - -```bash -$ weexpack init appName -``` - -weexpack ä¼èªå¨æ°å»ºä»¥ appName å½åçç®å½ï¼å¹¶å°é¡¹ç®æ¨¡æ¿æåå°è¯¥ç®å½ã - -æç»å½¢æå¦ä¸ç®å½ç»æï¼ - -```bash --> /appName -. -|ââ .gitignore -|ââ README.md -|ââ package.json -|-- android.config.json -|-- ios.config.json -|ââ webpack.config.js -|ââ /src -| |ââ index.we -|ââ /html5 -| |ââ index.html -|ââ /ios -| |ââ /playground -| |ââ /sdk -| |ââ /WXDevtool -|ââ /android -| |ââ /playground -| |ââ /appframework -``` - -å ¶ä¸ï¼ - -- `webpack.config.js` æ¯ webpack é ç½®æ件ï¼ç¨äºçæ `.we` æ件ç JSBunlde -- `ios.config.json` æ¯ iOS 项ç®é ç½®æ件 -- `android.config.json` æ¯ Android 项ç®é ç½®æ件 -- `/src` ç®å½æ¾ç½® Weex é¡µé¢ -- `/html5` æ¯ H5 ç«¯å ¥å£æ件 -- `/ios` æ¾ç½® iOS é¡¹ç® -- `/android` æ¾ç½® Android é¡¹ç® - -ç´§æ¥çï¼è¿å ¥ç®å½ï¼å¹¶ä¸å®è£ ä¾èµï¼ - -```bash -$ cd appName && npm install -``` - -è³æ¤ï¼é¡¹ç®æ¨¡çå建å®æï¼æ¥ä¸æ¥æ们å¯ä»¥èªå®ä¹æ们ç APP ä¿¡æ¯å¹¶æå è¿è¡ã - -### è¿è¡ä¸æå - -å¦æä¸åæ£å¸¸ï¼ä½ å¯ä»¥ä½¿ç¨ weexpack æå æ模æå¨è¿è¡äºï¼ - -Android çæå åæ建æ¯ä¸ä½ç ï¼ - -```bash -$ weexpack run android -``` - -åæ ·çä½ å¯ä»¥æ´æ¹é¡¹ç®ç®å½ä¸çandroid.config.json - -- `AppName`: åºç¨å -- `AppId`: application_id å å -- `SplashText`: 欢è¿é¡µä¸é¢çæå -- `WeexBundle`: æå®ç weex bundle æ件ï¼æ¯ææ件åå url çå½¢å¼ï¼ - - æå®æ件åå以æ¬å°æ件çæ¹å¼å è½½ bundleï¼æå® url å以è¿ç¨çæ¹å¼å è½½ JSBundleãå¦æ以æ¬å°æ¹å¼æå® bundle `.we` æ件请æ¾å° `src` ç®å½ã http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/customize-a-native-component.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/customize-a-native-component.md b/doc/source/cn/v-0.10/advanced/customize-a-native-component.md deleted file mode 100644 index 404f25c..0000000 --- a/doc/source/cn/v-0.10/advanced/customize-a-native-component.md +++ /dev/null @@ -1,168 +0,0 @@ ---- -title: èªå®ä¹ native ç»ä»¶ -type: advanced -order: 7 -has_chapter_content: true -version: 0.10 ---- - -# å¦ä½èªå®ä¹ native ç»ä»¶ï¼ - -Weex å·²ç»å å«äºæå ³é®çå¹³å°ç»ä»¶ï¼ä¾å¦ `ScrollView, ListView, Text, Imageview` ççãå½ç¶ï¼è¿äºç»ä»¶å¹¶ä¸è½å®å ¨æ»¡è¶³ä½ çéæ±ãå¦å¤ï¼é£äºå¨ä½ çå·¥ç¨ä¸å¸¸ç¨ç大éåç UI ç»ä»¶ï¼å¯è½éè¦è¢«ç®åå°éåå° Weex ä¸ã幸è¿çæ¯ï¼éè¿ä»»æå·²åå¨çç»ä»¶æ¥åå»ºä½ çèªå®ä¹ç»ä»¶æ¯ä¸ä»¶å¾æ¹ä¾¿çäºã - -## Android - -### æ¥éª¤ï¼ - -1.èªå®ä¹ç»ä»¶å¿ 须继æ¿èª `WXComponent` æè `WXContainer` ï¼ -2.weex SDK å¯ä»¥è¯å« @WXComponentProp (name = value(value æ¯ attr æè dsl style))ï¼ -3.æ¹æ³å¿ é¡»æ¯ `public` çï¼ -4.ç»ä»¶ç±»ä¸è½æ¯ä¸ä¸ªå é¨ç±»ï¼ -5.èªå®ä¹ç»ä»¶ä¸è½è¢« ProGuard ä¹ç±»çå·¥å ·æ··æ·ï¼ -6.ç»ä»¶æ¹æ³å¨ UI 线ç¨è¢«è°ç¨ï¼å æ¤ä¸è¦å¨éé¢è¿è¡èæ¶çæä½ï¼ -7.Weex çåæ°ç±»åå¯ä»¥æ¯ int, double, float, String, Map, List åå®ç°äº WXObject æ¥å£çèªå®ä¹ç±»ï¼ - -### åè以ä¸ä¾åï¼ - -``` java - `package com.taobao.weex.ui.component; -// â¦â¦ - -public class MyViewComponent extends WXComponent{ - - public MyViewComponent(WXSDKInstance instance, WXDomObject node, - WXVContainer parent, String instanceId, boolean lazy) { - super(instance, node, parent, instanceId, lazy); - } - - @Override - protected void initView() { - //TODO:your own code â¦â¦ - } - - @Override - public WXFrameLayout getView() { - //TODO:your own code â¦â¦â¦ - } - @WXComponentProp(name=WXDomPropConstant.WX_ATTR_VALUE) - public void setMyViewValue(String value) { - ((TextView)mHost).setText(value); - } - -} -``` - -å¿ é¡»æ³¨åç»ä»¶ï¼ - -``` java -WXSDKEngine.registerComponent("MyView", MyViewComponent.class); -``` - -## iOS - -è½ç¶ WeexSDK ä¸æå¾å¤ç native ç Componentï¼ä½è¿æå¯è½å¹¶ä¸è½æ»¡è¶³ä½ çéæ±ãå¨ä¹åä½ å¯è½å·²ç»åäºä¸äºå¾é ·ç« native çç»ä»¶ï¼æ³å è£ ä¸ä¸ï¼å¯¼å ¥å° Weex ä¸ï¼å æ¤æ们æä¾äºè®©å¼åè å®ç°èªå·±ç native Componentãä¸é¢å°ä»¥ WeexSDK ä¸å·²ç»åå¨ç Componentï¼`image` 为ä¾åï¼ä»ç»ä¸ä¸å¦ä½æ建ä¸ä¸ª native Componentãåè®¾ä½ å·²ç»äºè§£ iOS å¼å - -### 注å Component - -注åä¸ä¸ª component æ¯è¾ç®åï¼è°ç¨ `WXSDKEngine` ä¸ç `registerComponent:withClass:` æ¹æ³ï¼ä¼ å ¥ç»ä»¶çæ ç¾å称ï¼è¿æ对åºç class ç¶åä½ å¯ä»¥å建ä¸ä¸ª `WXImageComponent` 表示 `image` ç»ä»¶çå®ç°ãå¨ `.we` æ件ä¸ï¼åªéè¦å `<image></image>` - -### æ·»å å±æ§ - -ç°å¨æ们è¦åä¸äºè®© image component æ´å 强大çäºæ ãæ¢ç¶ä½ä¸ºä¸ä¸ªå¾çç componentï¼é£å®åºè¯¥è¦ææºï¼ç»ä»å ä¸ä¸ä¸ª `src` çå±æ§ï¼åæ¶ç»å®å ä¸ä¸ä¸ª `resize` çå±æ§ï¼å¯ä»¥é ç½®çæ `contain/cover/stretch`ï¼ - -```object-c -@interface WXImageComponent () - -@property (nonatomic, strong) NSString *imageSrc; -@property (nonatomic, assign) UIViewContentMode resizeMode; - -@end -``` - -component ä¸ææç styleï¼attributeï¼events é½ä¼è¢«ä¼ éå° Component çåå§åæ¹æ³ä¸ï¼æ以ï¼ä½ å¯ä»¥å¨åå§åæ¹æ³ä¸åå¨ä½ æå ´è¶£çä¸äºå±æ§å¼ - -```object-c -@implementation WXImageComponent - -- (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance -{ - if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) { - _imageSrc = [WXConvert NSString:attributes[@"src"]]; - _resizeMode = [WXConvert UIViewContentMode:attributes[@"resize"]]; -} - - return self; -} - -@end -``` - -attribute ä¸æ¿å°çå¼çç±»åé½æ¯ `id`ï¼æ们å¯ä»¥ç¨è½¬æ¢æ¹æ³æå®è½¬æ¢å°ä»»ä½å¼ãWeex SDK æä¾äºä¸äºåºç¡ç转æ¢æ¹æ³ï¼å¯ä»¥åè `WXConvert` ç±»ï¼æè ä½ å¯ä»¥æ·»å èªå·±ç转æ¢å½æ°ã - -### Hooking 渲æçå½å¨æ - -native ç component æ¯ç± Weex 管ççï¼Weex å建ï¼å¸å±ï¼æ¸²æï¼éæ¯ãWeex ç component çå½å¨æé½æ¯å¯ä»¥ hook çï¼ä½ å¯ä»¥å¨è¿äºçå½å¨æä¸å»åèªå·±çäºæ ã - -| æ¹æ³ | æè¿° | -| :-: | --- | -| initWithRef:type:... | ç¨ç»å®çå±æ§åå§åä¸ä¸ªcomponent. | -| layoutDidFinish | å¨componentå®æå¸å±æ¶åä¼è°ç¨. | -| loadView | å建component管ççview. | -| viewWillLoad | å¨componentçviewå è½½ä¹åä¼è°ç¨. | -| viewDidLoad | å¨componentçviewå è½½å®ä¹åè°ç¨. | -| viewWillUnload | å¨componentçview被éæ¾ä¹åè°ç¨. | -| viewDidUnload | å¨componentçview被éæ¾ä¹åè°ç¨. | -| updateStyles: | å¨componentçstyleæ´æ°æ¶åè°ç¨. | -| updateAttributes: | å¨componentçattributeæ´æ°æ¶åè°ç¨. | -| addEvent: | ç»componentæ·»å eventçæ¶åè°ç¨. | -| removeEvent: | å¨event移é¤çæ¶åè°ç¨. | - -å¨ image component çä¾åéé¢ï¼å¦ææ们éè¦æ们èªå·±ç image view çè¯ï¼å¯ä»¥å¤å `loadView`è¿ä¸ªæ¹æ³. - -```object-c -- (UIView *)loadView -{ -return [[WXImageView alloc] init]; -} -``` - -ç°å¨æä»¬ä½¿ç¨ `WXImageView` 渲æ `image` componentã -ä½ä¸ºä¸ä¸ª image componentï¼æ们éè¦æ¿å°æå¡å¨å¾çï¼èä¸æå®è®¾ç½®è¿ image view é. è¿ä¸ªæä½å¯ä»¥å¨ `viewDidLoad` æ¹æ³ä¸åï¼è¿ä¸ªæ¹æ³æ¯å¨ view å·²ç»è¢«å建èä¸å è½½äºæ¶å Weex SDK ä¼è°ç¨å°ï¼èä¸ `viewDidLoad` è¿ä¸ªæ¹æ³æ¯ä½ åé¢å¤åå§åå·¥ä½æ¯å¦æ¹å content mode(ä¹å°±æ¯è®¾ç½®resize) çæ好æ¶é´. - -```object-c -- (void)viewDidLoad -{ - UIImageView *imageView = (UIImageView *)self.view; - imageView.contentMode = _resizeMode; - imageView.userInteractionEnabled = YES; - imageView.clipsToBounds = YES; - imageView.exclusiveTouch = YES; - - // Do your image fetching and updating logic -} -``` - -å¦æå¯ä»¥æ¹å image ç srcï¼ä¹å¯ä»¥ hook `updateAttributes:` æ¹æ³æ¥åå±æ§æ´æ°æä½ï¼å½ `updateAttributes:` æè `updateStyles:` 被è°ç¨çæ¶åï¼ component ç view å·²ç»å è½½å®æ - -```object-c -- (void)updateAttributes:(NSDictionary *)attributes -{ - if (attributes[@"src"]) { - _imageSrc = [WXConvert NSString:attributes[@"src"]]; - // Do your image updating logic - } - - if (attributes[@"resize"]) { - _resizeMode = [WXConvert UIViewContentMode:attributes[@"resize"]]; - self.view.contentMode = _resizeMode; - } -} -``` - -æè®¸ä½ éè¦èèæ´å¤ççå½å¨ææ¹æ³å» Hookï¼å½å¸å±å®ææ¶åï¼å `layoutDidFinish`ï¼å¦æä½ æ³äºè§£æ´å¤ï¼å¯ä»¥åèä¸ä¸`WXComponent.h` 声æçæ¹æ³ã - -ç°å¨ä½ å¯ä»¥ç¨å¨ä»»ä½ `.we` æ件éé¢ä½¿ç¨ `<image>`ï¼èä¸å¯ä»¥å ä¸ image çå±æ§ã - -```html -<image style="your-custom-style" src="image-remote-source" resize="contain/cover/stretch"></image> -``` http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/cuszomize-native-apis.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/cuszomize-native-apis.md b/doc/source/cn/v-0.10/advanced/cuszomize-native-apis.md deleted file mode 100644 index 55e5e4c..0000000 --- a/doc/source/cn/v-0.10/advanced/cuszomize-native-apis.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -title: èªå®ä¹ native API -type: advanced -order: 8 -has_chapter_content: true -version: 0.10 ---- - -# å¦ä½èªå®ä¹ native APIï¼ - -Weex ç SDK åªæä¾äºé¡µé¢æ¸²æçè½åï¼ä½æ¯ä¸äºå ¶å®æä½ï¼æ¯å¦ç½ç»è¯·æ±ãå¾çå è½½ãéå®åçåè½éè¦ä½ èªå·±å»å®ç°ï¼è¿ä¸ªä¾å讲述äºå¦ä½ç¨åç代ç å»æ©å± Weex çåè½ã - -## å ³äº URLHelper çä¾å - -### æ°å»ºä¸ä¸ª WXModule - -```java -public class URLHelperModule extends WXModule{ - private static final String WEEX_CATEGORY="com.taobao.android.intent.category.WEEX"; - @WXModuleAnno - public void openURL(String url){ - if (TextUtils.isEmpty(url)) { - return; - } - StringBuilder builder=new StringBuilder("http:"); - builder.append(url); - Uri uri = Uri.parse(builder.toString()); - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - intent.addCategory(WEEX_CATEGORY); - mWXSDKInstance.getContext().startActivity(intent); - } -} -``` - -è¿éè¦æ³¨æ `@WXModuleAnno` è¿ä¸ªæ³¨è§£ï¼å®è¡¨ç¤ºäºä½ æè¿ä¸ªæ¹æ³æ´é²ç» JavaScriptã - -```java -public class URLHelperModule extends WXModule{ - - @WXModuleAnno - public void openURL(String url,String callbackId){ - //... - //callback to javascript - Map<String, Object> result = new HashMap<String, Object>(); - result.put("ts", System.currentTimeMillis()); - WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, result); - } -} -``` - -### æmodule注åå°WXSDKEngineï¼ - -```java -try { - WXSDKEngine.registerModule("myURL", URLHelperModule.class); - //'myURL' is the name you'll use in javascript - } catch (WXException e) { - WXLogUtils.e(e.getMessage()); - } -``` - -### å¨ JavaScript ä¸ä½¿ç¨ `eventModule`ï¼ - -```javascript -let URLHelper = require('@weex-module/myURL');//same as you registered -URLHelper.openURL("http://www.taobao.com",function(ts){ - console.log("url is open at "+ts); -}); -``` - -## ä¸äºæ³¨æäºé¡¹ï¼ - -1. å®ä¹ä¸ä¸ª components éè¦ç»§æ¿ `WXModule` - -2. ä¸è¦å¿è®°æ·»å `@WXModuleAnno` 注解ï¼ä¸ç¶ Weex 没æ³è¯å«è¿ä¸ªæ¹æ³ - -3. å®ä¹çæ¹æ³å¿ é¡»æ¯ `public ç - -4. module ç±»ä¸å®ä¸è½æ¯å é¨ç±» - -5. ä½ å®ä¹ç components ä¸è½è¢«æ··æ·ï¼ä¸ç¶ä¼æ¾ä¸å° - -6. Module ä¸çæ¹æ³ä¼å¨ UI 线ç¨ä¸è¢«è°ç¨ï¼æ以ä¸å®ä¸è¦åä¸äºèæ¶æä½ - -7. Moudle ä¸çæ¹æ³åæ°ç±»åå¯ä»¥ä¸º `int`ï¼`double`ï¼`float`ï¼`String`ï¼`Map`ï¼`List`ï¼ä»¥åå®ç° `WXObject` æ¥å£çç±»ã http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/extend-to-android.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/extend-to-android.md b/doc/source/cn/v-0.10/advanced/extend-to-android.md deleted file mode 100644 index f816ebd..0000000 --- a/doc/source/cn/v-0.10/advanced/extend-to-android.md +++ /dev/null @@ -1,170 +0,0 @@ ---- -title: Android æ©å± -type: advanced -order: 9 -has_chapter_content: true -version: 0.10 ---- - -# Android æ©å± - -Weex æä¾äºæ©å±æºå¶ï¼å¯ä»¥æ ¹æ®èªå·±çä¸å¡è¿è¡å®å¶èªå·±çåè½ã -主è¦å为两类æ©å±ï¼ - -- Module æ©å± é UI çç¹å®åè½ãä¾å¦ sendHttpãopenURL çã -- Component æ©å± å®ç°ç¹å«åè½ç Native æ§ä»¶ãä¾å¦ï¼RichTextviewï¼RefreshListview çã -- Adapter æ©å± Weex 对ä¸äºåºç¡åè½å®ç°äºç»ä¸çæ¥å£ï¼å¯å®ç°è¿äºæ¥å£æ¥å®å¶èªå·±çä¸å¡ãä¾å¦ï¼å¾çä¸è½½çã - -## Module æ©å± - -1. Module æ©å±å¿ é¡»ç»§æ¿ WXModule ç±»ã -2. æ©å±æ¹æ³å¿ é¡»å ä¸ @WXModuleAnno 注解ãWeex ä¼æ ¹æ®æ³¨è§£æ¥å¤æå½åæ¹æ³æ¯å¦è¦è¿è¡å¨ UI 线ç¨ï¼åå½åæ¹æ³æ¯å¦æ¯æ©å±æ¹æ³ã -3. Weexæ¯æ ¹æ®åå°æ¥è¿è¡è°ç¨ Module æ©å±æ¹æ³ï¼æ以Moduleä¸çæ©å±æ¹æ³å¿ é¡»æ¯ public ç±»åã -4. åæ ·å 为æ¯éè¿åå°è°ç¨ï¼Module ä¸è½è¢«æ··æ·ã请å¨æ··æ·æ件ä¸æ·»å 代ç ï¼`-keep public class * extends com.taobao.weex.common.WXModule{*;}` -5. Module æ©å±çæ¹æ³å¯ä»¥ä½¿ç¨ int, double, float, String, Map, List ç±»åçåæ° -6. å®æ Module åä¸å®è¦å¨åå§åæ¶æ³¨å `WXSDKEngine.registerModule("myModule", MyModule.class);` å¦åä¼æ¥ç±»ä¼¼é误ï¼`ReportException :undefined:9: TypeError: Object #<Object> has no method 'printLog'` - -示ä¾å¦ä¸ï¼ - -```java -public class MyModule extends WXModule { - - @WXModuleAnno(runOnUIThread = true) - public void printLog(String msg) { - Toast.makeText(mWXSDKInstance.getContext(),msg,Toast.LENGTH_SHORT).show(); - } -} -``` - -JS è°ç¨å¦ä¸ï¼ - -```html -<template> - <div> - <text onclick="click">ç¹å»ææµè¯</text> - </div> -</template> - -<script> - module.exports = { - methods: { - click: function() { - require('@weex-module/myModule').printLog("ææ¯ä¸ä¸ªæµè¯!"); - } - } - } -</script> -``` - -## Component æ©å± - -1. Component æ©å±ç±»å¿ é¡»éæ WXComponent. -2. Component 对åºç设置å±æ§çæ¹æ³å¿ 须添å 注解 @WXComponentProp(name=value(value is attr or style of dsl)) -3. Weex sdk éè¿åå°è°ç¨å¯¹åºçæ¹æ³ï¼æ以 Component 对åºçå±æ§æ¹æ³å¿ é¡»æ¯ publicï¼å¹¶ä¸ä¸è½è¢«æ··æ·ã请å¨æ··æ·æ件ä¸æ·»å 代ç `-keep public class * extends com.taobao.weex.ui.component.WXComponent{*;}` -4. Component æ©å±çæ¹æ³å¯ä»¥ä½¿ç¨ int, double, float, String, Map, List ç±»åçåæ° -5. å®æ Component åä¸å®è¦å¨åå§åæ¶æ³¨å `WXSDKEngine.registerComponent("richtext",RichText.class);` - -示ä¾å¦ä¸: - -```java -public class RichText extends WXComponent { - - public RichText(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, boolean isLazy) { - super(instance, dom, parent, isLazy); - } - - @Override - protected void initView() { - mHost=new TextView(mContext); - ((TextView)mHost).setMovementMethod(LinkMovementMethod.getInstance()); - } - - @WXComponentProp(name = "tel") - public void setTelLink(String tel){ - SpannableString spannable=new SpannableString(tel); - spannable.setSpan(new URLSpan("tel:"+tel),0,tel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - ((TextView)mHost).setText(spannable); - } -} -``` - -JS è°ç¨å¦ä¸ï¼ - -```html -<template> - <div> - <richText tel="12305" style="width:200;height:100">12305</text> - </div> -</template> -``` -## Adapteræ©å± - -å¾çä¸è½½ï¼ - -éè¦æ¶éææ¥å£ IWXImgLoaderAdapterï¼å®ç° setImage æ¹æ³ã - -示ä¾å¦ä¸ï¼ - -```java -public class ImageAdapter implements IWXImgLoaderAdapter { - - public ImageAdapter() { - } - - @Override - public void setImage(final String url, final ImageView view, - WXImageQuality quality, WXImageStrategy strategy) { - - WXSDKManager.getInstance().postOnUiThread(new Runnable() { - - @Override - public void run() { - if(view==null||view.getLayoutParams()==null){ - return; - } - if (TextUtils.isEmpty(url)) { - view.setImageBitmap(null); - return; - } - String temp = url; - if (url.startsWith("//")) { - temp = "http:" + url; - } - if (view.getLayoutParams().width <= 0 || view.getLayoutParams().height <= 0) { - return; - } - Picasso.with(WXEnvironment.getApplication()) - .load(temp) - .into(view); - } - },0); - } -} -``` -#### ç»ä»¶æ¹æ³æ¯æ -ä»WeexSDK 0.9.5å¼å§ï¼ä½ å¯ä»¥å®ä¹ç»ä»¶æ¹æ³ - -- å¨ç»ä»¶ä¸å¦ä¸å£°æä¸ä¸ªç»ä»¶æ¹æ³ - - ```java - @JSMethod - public void focus(){ - //method implementation - } - ``` -- 注åç»ä¹åï¼ä½ å¯ä»¥å¨weex æ件ä¸è°ç¨ - - ```html - <template> - <mycomponent id='mycomponent'></mycomponent> - </template> - <script> - module.exports = { - created: function() { - this.$el('mycomponent').focus(); - } - } - </script> - ``` - -注:å·¥ç¨è¦æ·»å ä¾èµ `compile 'com.squareup.picasso:picasso:2.5.2'` http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/extend-to-html5.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/extend-to-html5.md b/doc/source/cn/v-0.10/advanced/extend-to-html5.md deleted file mode 100644 index ff99629..0000000 --- a/doc/source/cn/v-0.10/advanced/extend-to-html5.md +++ /dev/null @@ -1,253 +0,0 @@ ---- -title: weex-html5 æ©å± -type: advanced -order: 11 -has_chapter_content: true -version: 0.10 ---- - -# æ©å± weex-html5 - -### ç®ä» - -Weex æ¯ä¸ä¸ªé«å¯æ©å±æ§ç跨平å°å¨æåå¼åæ¹æ¡ï¼ä½ å¯ä»¥å¨ç°æç»ä»¶åºç¡ä¸å®å¶èªå·±éè¦çä¸ç«¯ç»ä»¶ãä½ å¯ä»¥ä¸º Weex API 模åæ·»å æ°çæ¹æ³ï¼æè å建æ°ç API 模ååæ°çå è½½å¨ãæç §ä»¥ä¸å 个æ¥éª¤æ©å±ä½ çç»ä»¶ï¼API æè å è½½å¨ã - -é¦å è¦æç¡®çæ¯ï¼ç»ä»¶å API 模åæ¯åºäº Weex çæ©å±ï¼ä½æ¯ç¬ç«äº Weexï¼ç»ä»¶çå®ä¹æ¬èº«æ¯ä¸éè¦ä¾èµäº Weex çï¼è¿æ ·æå©äºç»ä»¶çåæ£å管çï¼å»é¤ä¸å¿åä¾èµã - -å ¶æ¬¡ï¼å½ä½ æ©å±ä¸ä¸ªç»ä»¶ï¼ä½ éè¦åæ¶æ©å±ä¸ç«¯çç»ä»¶ï¼android, ios å web 端ï¼ï¼æ¯ç« Weex æ¯ä¸ä¸ªéè§ä¸ç«¯ä¸è´ä½éªç跨平å°ç§»å¨æ¡æ¶ãä½ å¯ä»¥ä¸ä¸ªç«¯ä¸ä¸ªç«¯çæ©å±ï¼ä¹å¯ä»¥å¬å¤å ¶ä»ç«¯ä¸çå¼åè æ¥å ±åå®æä½ å¨å ¶ä»ç«¯ä¸çç»ä»¶ï¼ä½ æ»æ¯å¯ä»¥å¨ç¤¾åºæ¾å°å¯¹æ个åè½æå ±åéæ±çå¼åè ï¼ãè¿éæä¸äºå¨ [android 端](./extend-to-android.md)å [ios 端](./extend-to-ios.md)åæ©å±çææ¡£å¯ä»¥åèã - -ä½ åºè¯¥å°ä½ çæ©å±åå¸å° Weex å¼åè å¯ä»¥æ¹ä¾¿æ¾å°å使ç¨çæ¸ éï¼æ¯å¦ `npm`ãæ们æ¨èä½ å°ä½ å¼åçç»ä»¶åå¸å° `npm` ä¾å ¶ä» Weex å¼åè 使ç¨ã - -æéè¦çæ¯ï¼ä½ çç»ä»¶çå½åéè¦éµå® Weex ç»ä»¶å½åè§èï¼ä»¥ `weex-` å¼å¤´ä½ä¸ºç»ä»¶çåç¼ï¼å¹¶ä¸ä»¥ `-<platform>` å为ç»å°¾åç¼ï¼é¤éä½ åå¸çå æ¯ä¸ç«¯çå®ç°é½å å«å¨å çãè¿éæ个 [`<weex-hello-web`>](https://github.com/MrRaindrop/weex-hello-web) çä¾åä½ä¸ºåèï¼è¿é注åäºä¸ä¸ªç®åçèªå®ä¹çç»ä»¶ã - -### å建æ°ç»ä»¶ - -æ¥éª¤: -1. å¨ä½ çç»ä»¶å®ç°ä¸å¿ é¡»ç»§æ¿ `Weex.Component` è¿ä¸ªç±», 并éæ©æ§çéåå ¶ä¸çä¸äºæ¹æ³ã -2. ä½ çç»ä»¶ç exports éè¦æ´é²ä¸ä¸ª `init` æ¹æ³ï¼å¹¶å¨å ¶ä¸ä½¿ç¨ `Weex.registerComponent` 注åä½ çç»ä»¶ã - -**è¿éç¨ä¸ä¸ªä¾åå±ç¤ºå¦ä½æ©å±ä¸ä¸ªæ°çç»ä»¶** - -çè¿ä¸ªç»ä»¶æ©å±ç代ç ( web 端ä¸çç»ä»¶)ï¼ - -``` javascript -const attr = { - // ... -} -const style = { - // ... -} -const event = { - // ... -} -// æ¯ä¸ªæ©å±ç»ä»¶é½éè¦å®ç°ä¸ä¸ªinitæ¹æ³ï¼Weexä¼éè¿è¿æ¹æ³è¿è¡å®è£ å注å. -function init (Weex) { - const Component = Weex.Component - const extend = Weex.utils.extend - - // ç»ä»¶çæé å½æ° - function Hello (data) { - Component.call(this, data) - } - - // prototypeç»§æ¿ - Hello.prototype = Object.create(Component.prototype) - extend(Hello.prototype, proto) - - // é ç½®å±æ§ãæ ·å¼ä»¥åäºä»¶ - extend(Hello.prototype, { attr }) - extend(Hello.prototype, { - style: extend(Object.create(Component.prototype.style), style) - }) - extend(Hello.prototype, { event }) - - Weex.registerComponent('weex-hello', Hello) -} - -// æ´é²initæ¹æ³æ¥å£. -export default { init } -``` - -ä¸è¿°ä»£ç æå¼èª [weex-hello-web/src/index.js](https://github.com/MrRaindrop/weex-hello-web/blob/master/src/index.js#L46-L65) - -è¿ä¸ªdemoéåäºåºç±» `Component`ä¸ç`create`æ¹æ³ãä½ ä¹å¯ä»¥éæ©éå`Component`ä¸çä¸äºå ¶ä»æ¹æ³æ¥å®å¶ç»ä»¶çè¡ä¸ºãå ¸åçæ¹æ³å æ¬ï¼ -- `create`: å建ç»ä»¶çèç¹ï¼å¨æ¹æ³ä½ä¸returnè¿ä¸ªèç¹. -- `createChildren` å建åèç¹. -- `insertBefore` å¨æ个åèç¹ä¹åæå ¥ä¸ä¸ªæ°çåèç¹. -- `appendChild` å¨åèç¹å表çæåå ä¸ä¸ä¸ªèç¹. -- `removeChild` 移é¤ä¸ä¸ªåèç¹. - -**è¿é¶**ï¼æ´å¤å ³äºç»ä»¶å®å¶åæ©å±çç»èå代ç å±ç¤ºï¼å¯ä»¥åè [weex 主ä»åºç代ç ](https://github.com/apache/incubator-weex/tree/dev/html5)ï¼è¿éçç»ä»¶åºæ¬ä¸é½æ¯éè¿ä¸è¿°æ¹å¼è¿è¡å®ä¹çã - -éè¦çä¸ç¹ï¼æ³¨åç»ä»¶çå ³é®æ¹æ³æ¯ `Weex.registerComponent`ï¼å¦ç¤ºä¾éç `weex-hello` ç»ä»¶ç注åï¼ - -``` javascript -Weex.registerComponent('weex-hello', Hello) -``` - -ä¸è¿°ä»£ç å¼èª [weex-hello-web/src/index.js](https://github.com/MrRaindrop/weex-hello-web/blob/master/src/index.js#L62) - -å¨æ个éè¦ä½¿ç¨è¯¥ç»ä»¶çweex项ç®ä¸ä½¿ç¨ `Weex.install` æ¹æ³å®è£ 该ç»ä»¶ï¼ - -``` javascript -// import the original weex-html5. -import weex from 'weex-html5' -import hello from 'weex-hello-web' -// install the component. -weex.install(hello) -``` - -ä¸è¿°ä»£ç å¼èª [weex_extend_demo/src/main.js](https://github.com/MrRaindrop/weex_extend_demo/blob/master/src/main.js#L1-L5) - -å¨ä½ ç `.we` æ件ä¸ç´æ¥ä½¿ç¨è¿ä¸ªç»ä»¶ï¼ - -``` html -<template> - <div> - <weex-hello class="hello" style="txt-color:#fff;bg-color:green" - value="WEEX" onclick="handleClick"> - </weex-hello> - </div> -</template> -``` - -ä¸è¿°ä»£ç å¼èª[weex_extend_demo/demo/index.we](https://github.com/MrRaindrop/weex_extend_demo/blob/master/demo/index.we#L10-L15) -### æ©å±API - -ä½ å¯ä»¥æ©å±æ°ç API 模åï¼æè 为æ个已æç模åæ·»å æ°ç API. æ¯å¦ï¼ä½ å¯ä»¥æ·»å ä¸ä¸ª API 模åå«å `user`ï¼å¨éé¢æ·»å ä¸äºç¨æ·ç»å½ç»åºå¤çç APIï¼æ¯å¦ `login`, `logout` ççãä½ å¯ä»¥éè¿ `require('@weex-module/moduleName)[methodName](arg1, arg2, ...)` ([Module APIs](../references/api.md)) çæ¹å¼è°ç¨ä½ ç API. - -æ¥éª¤: -1. å®ç°ä½ ç API module. -2. å¨ä½ ç API å®è£ 模åéæ´é²ä¸ä¸ª `init` æ¹æ³ï¼å¹¶å¨è¿ä¸ªæ¹æ³éé¢ä½¿ç¨ `Weex.registerAPIModules` 注åä½ ç API module. - -**è¿éç¨ä¸ä¸ªä¾åå±ç¤ºå¦ä½æ©å±ä¸ä¸ªæ°ç API 模å** - -å建ä¸ä¸ªæ件 `user.js`ï¼å¨å ¶ä¸å®ä¹ç»å½ç»åº `login/logout` æ¹æ³. - -``` javascript -const user = { - // å®ä¹ç¨æ·ç»å½æ¹æ³. - login (callbackId) { - login.then(res => { - this.sender.performCallback(callbackId, res) - }).catch(err => { - this.sender.performCallback(callbackId, err) - }) - }, - - // å®ä¹ç¨æ·ç»åºæ¹æ³. - logout (callbackId) { - logout.then(res => { - this.sender.performCallback(callbackId, res) - }).catch(err => { - this.sender.performCallback(callbackId, err) - }) - } -} - -// å®ä¹user模åçå (meta) ä¿¡æ¯. -const meta = { - user: [{ - name: 'login', - args: ['function'] - }, { - name: 'logout', - args: ['function'] - }] -} - -export default { - init (Weex) { - // 注åè¿ä¸ªæ¨¡åï¼æåä¸ä¸ªåæ°æ¯æ¨¡åçå ä¿¡æ¯. - Weex.registerApiModule('user', user, meta) - } -} -``` - -è¿ä¸ªç®åç user helper 模åå°±å®ç°å¥½äºï¼å¯ä»¥åå¸å° npm ä¸ï¼æ们å¯ä»¥ç»è¿ä¸ªæ¨¡åå个ååï¼æ¯å¦è¯´ `weex-user-helper`ã - -å¨ä½ çæ°ç Weex 项ç®éå®è£ è¿ä¸ªæ¨¡å: - -``` javascript -import Weex from 'weex-html5' -import user from 'weex-user-helper' - -Weex.install(user) -``` - -å®è£ äºè¿ä¸ªæ¨¡åï¼ä½ å°±å¯ä»¥å¨ DSL 代ç éå¼ç¨è¿ä¸ªæ¨¡åå¹²ç¹äºæ äº: - -``` html -<template> - <div> - <div class="btn" onclick="handleClick"> - <text>LOGIN</text> - </div> - </div> -</template> - -<script> - var userHelper = require('@weex-module/user') - module.exports = { - methods: { - handleClick: function () { - userHelper.login(function () { - // ... do sth. in callback. - }) - } - } - } -</script> -``` - -### å®å¶å è½½å¨loader - -**Loaderä» ç¨äºweex-html5 (web端)å è½½dslæå åºæ¥çbundle代ç ï¼nativeå¹³å°æå ¶ä»çå è½½æºå¶** - -å·²æçå è½½å¨å æ¬ `xhr`, `jsonp` å `source`. ä½ å¯ä»¥ä½¿ç¨ `weex.registerLoader` 注åä¸ä¸ªæ°çå è½½å¨ãä¾å¦ï¼ä½ æä¸ä¸ªè·å Weex bundle çæå¡ `myServe.getWeexBundle` , éè¿è¿ä¸ªæå¡å¯ä»¥å è½½ weex bundleï¼ä¸ºæ¤ä½ å¯ä»¥å®ä¹ä¸ä¸ªå è½½å¨ï¼ - -``` javascript -function loadByMyServe(pageId, callback) { - myServe.getWeexBundle(pageId).then(function (bundle) { - callback(bundle) - }).catch(function(err) { - callback(err) - }) -} - -// æ´é²initæ¹æ³ç¨äºWeexå®è£ æ¤å è½½å¨. -export default { - init (Weex) { - Weex.registerLoader('myserve', loadByMyServe) - } -} -``` - -å¨ä½ ç weex-html5 项ç®çå¯å¨æ件éå®è£ 并使ç¨è¿ä¸ªå è½½å¨ï¼ - -``` javascript -import Weex from 'weex-html5' - -// æè import from './myserve.js'ï¼ä¸ç®¡æ¯importä¸ä¸ªnpm模åè¿æ¯importä¸ä¸ªæ件. -import loader from 'myLoader' - -Weex.install(loader) - -// å¨initæ¹æ³é使ç¨è¿ä¸ªå è½½å¨å è½½bundleæ件. -(function () { - function getUrlParam (key) { - const reg = new RegExp('[?|&]' + key + '=([^&]+)') - const match = location.search.match(reg) - return match && match[1] - } - const page = getUrlParam('page') || 'examples/build/index.js' - Weex.init({ - appId: location.href, - loader: 'myserve', // 使ç¨åæå®ä¹çloaderç±»å - source: page, - rootId: 'weex' - }) -})(); -``` - -以ä¸æ¯ Weex 带æ¥çæ©å±æ§éæ¯è¾ä¸»è¦çä¸é¨åï¼æ´å¤å®ç°ç»èå¯ä»¥å¨ [weex 项ç®ä»£ç åº](https://github.com/alibaba/weex)以å weex çå¼æºç¤¾åºéæ¾å°ã http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/extend-to-ios.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/extend-to-ios.md b/doc/source/cn/v-0.10/advanced/extend-to-ios.md deleted file mode 100644 index b163d62..0000000 --- a/doc/source/cn/v-0.10/advanced/extend-to-ios.md +++ /dev/null @@ -1,279 +0,0 @@ ---- -title: iOS æ©å± -type: advanced -order: 10 -has_chapter_content: true -version: 0.10 ---- - -## iOS æ©å± - -### Module æ©å± - -[swift](https://github.com/weexteam/article/issues/55) æ©å± module - -Weex SDK åªæä¾æ¸²æï¼èä¸æ¯å ¶ä»çè½åï¼å¦æä½ éè¦ åç½ç»ï¼å¾çï¼URL跳转è¿äºç¹æ§ï¼éè¦èªå·±å¨æå®ç°ä»ä»¬ -ä¾å¦ï¼å¦æä½ æ³å®ç°ä¸ä¸ªurlå°å跳转å½æ°ï¼ä½ å¯ä»¥æç §å¦ä¸æ¥éª¤å®ç°ä¸ä¸ª Module -1. **èªå®ä¹moduleçæ¥éª¤** - 1. èªå®ä¹çmoduleç±» å¿ é¡»å®ç° `WXModuleProtocol` - 2. å¿ é¡»æ·»å å®`WX_EXPORT_METHOD`, å®å¯ä»¥è¢«weexè¯å«ï¼å®çåæ°æ¯ JavaScriptè°ç¨ moduleæå®æ¹æ³çåæ° - 3. æ·»å `@synthesized weexInstance`ï¼æ¯ä¸ªmoudle对象被ç»å®å°ä¸ä¸ªæå®çå®ä¾ä¸ - 4. Module æ¹æ³ä¼å¨UI线ç¨ä¸è¢«è°ç¨ï¼æ以ä¸è¦å太å¤èæ¶çä»»å¡å¨è¿éï¼å¦æè¦å¨å ¶ä»çº¿ç¨æ§è¡æ´ä¸ªmodule æ¹æ³ï¼éè¦å®ç°`WXModuleProtocol`ä¸`- (NSThread *)targetExecuteThread`çæ¹æ³ï¼è¿æ ·ï¼ååå°è¿ä¸ªmoduleçä»»å¡ä¼å¨æå®ç线ç¨ä¸è¿è¡ - 5. Weex çåæ°å¯ä»¥æ¯ String æè Map - 6. Module æ¯æè¿åå¼ç» JavaScriptä¸çåè°ï¼åè°çç±»åæ¯`WXModuleCallback`,åè°çåæ°å¯ä»¥æ¯Stringæè Map - - ```object-c - @implementation WXEventModule - @synthesize weexInstance; - WX_EXPORT_METHOD(@selector(openURL:callback)) - - (void)openURL:(NSString *)url callback:(WXModuleCallback)callback - { - NSString *newURL = url; - if ([url hasPrefix:@"//"]) { - newURL = [NSString stringWithFormat:@"http:%@", url]; - } else if (![url hasPrefix:@"http"]) { - newURL = [NSURL URLWithString:url relativeToURL:weexInstance.scriptURL].absoluteString; - } - - UIViewController *controller = [[WXDemoViewController alloc] init]; - ((WXDemoViewController *)controller).url = [NSURL URLWithString:newURL]; - - [[weexInstance.viewController navigationController] pushViewController:controller animated:YES]; - callback(@{@"result":@"success"}); - } - - @end - ``` -2. **Register the module** - éè¿è°ç¨ WXSDKEngine ä¸ç `registerModule:withClass`æ¹æ³æ¥æ³¨åèªå·±çmodule - - ```object-c - WXSDKEngine.h - /** - * @abstract Registers a module for a given name - * @param name The module name to register - * @param clazz The module class to register - **/ - + (void)registerModule:(NSString *)name withClass:(Class)clazz; - [WXSDKEngine registerModule:@"event" withClass:[WXEventModule class]]; - ``` -3. **使ç¨èªå·±çmodule** - è¿éç require éé¢çevent å°±æ¯å¨ ä¸ä¸æ¥è°ç¨`registerModule:` 注åmodule æ¶åçname - - ```javascript - var eventModule = require('@weex-module/event'); - eventModule.openURL('url',function(ret) { - nativeLog(ret); - }); - ``` - - Weex SDK没æ å¾çä¸è½½ï¼navigation æä½çè½åï¼è¯·å¤§å®¶èªå·±å®ç°è¿äº protocol - -### handler æ©å± - **WXImgLoaderProtocol** - - weexSDK 没ææä¾å¾çä¸è½½çè½åï¼éè¦å®ç° WXImgLoaderProtocol,åèä¸é¢çä¾å - - ```object-c - WXImageLoaderProtocol.h - @protocol WXImgLoaderProtocol <WXModuleProtocol> - /** - * @abstract Creates a image download handler with a given URL - * @param imageUrl The URL of the image to download - * @param imageFrame The frame of the image you want to set - * @param options : The options to be used for this download - * @param completedBlock : A block called once the download is completed. - image : the image which has been download to local. - error : the error which has happened in download. - finished : a Boolean value indicating whether download action has finished. - */ - -(id<WXImageOperationProtocol>)downloadImageWithURL:(NSString *)url imageFrame:(CGRect)imageFrame userInfo:(NSDictionary *)options completed:(void(^)(UIImage *image, NSError *error, BOOL finished))completedBlock; - @end - ``` - - å®ç°ä¸è¿°åè®® - - ```object-c - @implementation WXImgLoaderDefaultImpl - #pragma mark - - #pragma mark WXImgLoaderProtocol - - - (id<WXImageOperationProtocol>)downloadImageWithURL:(NSString *)url imageFrame:(CGRect)imageFrame userInfo:(NSDictionary *)userInfo completed:(void(^)(UIImage *image, NSError *error, BOOL finished))completedBlock - { - if ([url hasPrefix:@"//"]) { - url = [@"http:" stringByAppendingString:url]; - } - return (id<WXImageOperationProtocol>)[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:url] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { - } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, finished); - } - }]; - } - @end - ``` - -5. **handler注å** - - ä½ å¯ä»¥éè¿WXSDKEngine ä¸ç `registerHandler:withProtocol`注åhandler - - ```object-c - WXSDKEngine.h - /** - * @abstract Registers a handler for a given handler instance and specific protocol - * @param handler The handler instance to register - * @param protocol The protocol to confirm - */ - + (void)registerHandler:(id)handler withProtocol:(Protocol *)protocol; - - [WXSDKEngine registerHandler:[WXImgLoaderDefaultImpl new] withProtocol:@protocol(WXImgLoaderProtocol)] - ``` - -#### Component æ©å± - è½ç¶WeexSDKä¸ææä¾å ç½®çä¸äºComponentï¼ä½è¿æå¯è½å¹¶ä¸è½æ»¡è¶³ä½ çéæ±ãå¨ä¹åä½ å¯è½å·²ç»åäºä¸äºå¾é ·ç«nativeçç»ä»¶ï¼æ³å è£ ä¸ä¸ï¼å¯¼å ¥å°Weexä¸ï¼å æ¤æ们æä¾äºè®©å¼åè å®ç°èªå·±çnative Component - ä¸é¢å°ä»¥WeexSDK ä¸å·²ç»åå¨ç Componentï¼`image`为ä¾åï¼ä»ç»ä¸ä¸å¦ä½æ建ä¸ä¸ªnative Component. - åè®¾ä½ å·²ç»äºè§£IOSå¼å - 1. 注å Component - 注åä¸ä¸ªcomponentæ¯è¾ç®åï¼è°ç¨ `WXSDKEngine` ä¸ç `registerComponent:withClass:`æ¹æ³ï¼ä¼ å ¥ç»ä»¶çæ ç¾å称ï¼è¿æ对åºçclass - ç¶åä½ å¯ä»¥å建ä¸ä¸ª `WXImageComponent` 表示`image`ç»ä»¶çå®ç° å¨.we æ件ä¸ï¼åªéè¦å - <image></image> - 2. æ·»å å±æ§ - ç°å¨æ们è¦åä¸äºè®©image componentæ´å 强大çäºæ ãæ¢ç¶ä½ä¸ºä¸ä¸ªå¾ççcomponentï¼é£å®åºè¯¥è¦ææºï¼ç»ä»å ä¸ä¸ä¸ª `src`çå±æ§ï¼åæ¶ç»å®å ä¸ä¸ä¸ª`resize`çå±æ§ï¼å¯ä»¥é ç½®çæ`contain/cover/stretch`ï¼ - - ``` - @interface WXImageComponent () - - @property (nonatomic, strong) NSString *imageSrc; - @property (nonatomic, assign) UIViewContentMode resizeMode; - - @end - ``` - componentä¸ææçstyleï¼attributeï¼eventsé½ä¼è¢«ä¼ éå° Componentçåå§åæ¹æ³ä¸ï¼æ以ï¼ä½ å¯ä»¥å¨åå§åæ¹æ³ä¸åå¨ä½ æå ´è¶£çä¸äºå±æ§å¼ - - ``` - @implementation WXImageComponent - - - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance - { - if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) { - _imageSrc = [WXConvert NSString:attributes[@"src"]]; - _resizeMode = [WXConvert UIViewContentMode:attributes[@"resize"]]; - } - - return self; - } - - @end - ``` - - attributeä¸æ¿å°çå¼çç±»åé½æ¯`id`,æ们å¯ä»¥ç¨è½¬æ¢æ¹æ³æå®è½¬æ¢å°ä»»ä½å¼ãWeex SDKæä¾äºä¸äºåºç¡ç转æ¢æ¹æ³ï¼å¯ä»¥åè `WXConvert`ç±»ï¼æè ä½ å¯ä»¥æ·»å èªå·±ç转æ¢å½æ° - - 1. Hooking 渲æçå½å¨æ - native çcomponent æ¯ç±Weex管ççï¼weex å建ï¼å¸å±ï¼æ¸²æï¼éæ¯ãweexçcomponentçå½å¨æé½æ¯å¯ä»¥hookçï¼ä½ å¯ä»¥å¨è¿äºçå½å¨æä¸å»åèªå·±çäºæ - - | æ¹æ³ | æè¿° | - | :-: | --- | - | initWithRef:type:... | ç¨ç»å®çå±æ§åå§åä¸ä¸ªcomponent. | - | layoutDidFinish | å¨componentå®æå¸å±æ¶åä¼è°ç¨. | - | loadView | å建component管ççview. | - | viewWillLoad | å¨componentçviewå è½½ä¹åä¼è°ç¨. | - | viewDidLoad | å¨componentçviewå è½½å®ä¹åè°ç¨. | - | viewWillUnload | å¨componentçview被éæ¾ä¹åè°ç¨. | - | viewDidUnload | å¨componentçview被éæ¾ä¹åè°ç¨. | - | updateStyles: | å¨componentçstyleæ´æ°æ¶åè°ç¨. | - | updateAttributes: | å¨componentçattributeæ´æ°æ¶åè°ç¨. | - | addEvent: | ç»componentæ·»å eventçæ¶åè°ç¨. | - | removeEvent: | å¨event移é¤çæ¶åè°ç¨. | - - å¨image componentçä¾åéé¢ï¼å¦ææ们éè¦æ们èªå·±çimage view çè¯ï¼å¯ä»¥å¤å `loadView`è¿ä¸ªæ¹æ³. - - ``` - - (UIView *)loadView - { - return [[WXImageView alloc] init]; - } - ``` - - ç°å¨æä»¬ä½¿ç¨ `WXImageView` 渲æ `image` componentã - 1. ä½ä¸ºä¸ä¸ªimage componentï¼æ们éè¦æ¿å°æå¡å¨å¾çï¼èä¸æå®è®¾ç½®è¿image view é. è¿ä¸ªæä½å¯ä»¥å¨ `viewDidLoad` æ¹æ³ä¸åï¼è¿ä¸ªæ¹æ³æ¯å¨viewå·²ç»è¢«å建èä¸å è½½äºæ¶åweex SDKä¼è°ç¨å°ï¼èä¸`viewDidLoad`è¿ä¸ªæ¹æ³æ¯ä½ åé¢å¤åå§åå·¥ä½æ¯å¦æ¹åcontent mode(ä¹å°±æ¯è®¾ç½®resize) çæ好æ¶é´. - - ``` - - (void)viewDidLoad - { - UIImageView *imageView = (UIImageView *)self.view; - imageView.contentMode = _resizeMode; - imageView.userInteractionEnabled = YES; - imageView.clipsToBounds = YES; - imageView.exclusiveTouch = YES; - - // Do your image fetching and updating logic - } - ``` - - 1. å¦æå¯ä»¥æ¹åimageçsrc,ä¹å¯ä»¥hook `updateAttributes:`æ¹æ³æ¥åå±æ§æ´æ°æä½ï¼å½`updateAttributes:`æè `updateStyles:`被è°ç¨çæ¶åï¼ componentçview å·²ç»å è½½å®æ - - ``` - - (void)updateAttributes:(NSDictionary *)attributes - { - if (attributes[@"src"]) { - _imageSrc = [WXConvert NSString:attributes[@"src"]]; - // Do your image updating logic - } - - if (attributes[@"resize"]) { - _resizeMode = [WXConvert UIViewContentMode:attributes[@"resize"]]; - self.view.contentMode = _resizeMode; - } - } - ``` - - æè®¸ä½ éè¦èèæ´å¤ççå½å¨ææ¹æ³å»Hookï¼å½å¸å±å®ææ¶åï¼å`layoutDidFinish`ï¼å¦æä½ æ³äºè§£æ´å¤ï¼å¯ä»¥åèä¸ä¸`WXComponent.h` 声æçæ¹æ³ - ç°å¨ä½ å¯ä»¥ç¨å¨ä»»ä½ .weæ件éé¢ä½¿ç¨ `<image>`ï¼èä¸å¯ä»¥å ä¸ imageçå±æ§ - - ``` - <image style="your-custom-style" src="image-remote-source" resize="contain/cover/stretch"></image> - ``` -##### component æ¹æ³ -WeexSDK 0.9.5 ä¹åæ¯æäºå¨jsä¸ç´æ¥è°ç¨componentçæ¹æ³ï¼è¿éæä¾ä¸ä¸ªä¾åï¼ - -- èªå®ä¹ä¸ä¸ªWXMyCompoenent çç»ä»¶ - - ``` - @implementation WXMyComponent - WX_EXPORT_METHOD(@selector(focus)) // æ´é²è¯¥æ¹æ³ç»js - - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance - { - if (self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance]) { - // handle your attributes - // handle your styles - } - - return self; - } - - - (void)focus - { - NSLog(@"you got it"); - } - @end - ``` - -- 注åç»ä»¶ `[WXSDKEngine registerComponent:@"mycomponent" withClass:[WXMyComponent class]] ` -- å¨weex æ件ä¸è°ç¨ - - ```html - <template> - <mycomponent id='mycomponent'></mycomponent> - </template> - <script> - module.exports = { - created: function() { - this.$el('mycomponent').focus(); - } - } - </script> - ``` - - - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/how-data-binding-works.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/how-data-binding-works.md b/doc/source/cn/v-0.10/advanced/how-data-binding-works.md deleted file mode 100644 index a905422..0000000 --- a/doc/source/cn/v-0.10/advanced/how-data-binding-works.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: æ°æ®ç»å®åç -type: advanced -order: 2 -has_chapter_content: true -version: 0.10 ---- - -# æ°æ®ç»å®å®ç°åç - -Weex ç JS Framework æ¯ä¸ä¸ª MVVMï¼å³ Model-View-ViewModel æ¡æ¶ãä»ä¼èªå¨çå¬æ°æ®çååï¼å¹¶éè¿ `{% raw %}{{å段å}}{% endraw %}` çè¯æ³ææ°æ®åè§å¾ä¸æå±ç¤ºçå 容èªå¨ç»å®èµ·æ¥ãå½æ°æ®è¢«æ¹åçæ¶åï¼è§å¾ä¼èªå¨æ ¹æ®æ°æ®çååèåçç¸åºçååã - -æ¯å¦ä¸é¢è¿ä¸ªä¾åï¼`<text>` çå 容被ç»å®å¨äº `notes` æ°æ®å段ä¸ï¼ - -```html -<template> - <div> - <text>{{notes}}</text> - </div> -<template> - -<script> - module.exports = { - data: { - notes: 'Hello' - } - } -</script> -``` - -Weex ç JS Framework ä¼é¦å 对 `data` éçæ°æ®è¿è¡çå¬ï¼è¿æ ·æªæ¥çæ°æ®ååé½è½å¤è¢«çå¬å°ãç¶åæ们ä¼ç¼è¯æ´ä¸ª `<template>` æ ç¾éçå 容ãå½æ们æ¾å° `<text>` æ ç¾éç `{% raw %}{{notes}}{% endraw %}` æ¶ï¼JS Framework ä¼è·è¸ª `data.notes` çåå并å¨å ¶åçååæ¶è§¦åä¸ä¸ªå¥æï¼å° `<text>` çå 容设置为 `data.notes` ææ°çå¼ãè¿æ ·çè¯å¼åè å°±ä¸å¿ æå¨å ³å¿æ°æ®åè§å¾ä¹é´çæ°æ®åæ¥é®é¢äºã - -å¨è¿ä¸ªåºç¡ä¸æ们è¿è®¾è®¡äºä¸äºç¹æ®çè¯æ³ï¼ - -- `<foo if="...">` 代表ä¸ä¸ªæ¡ä»¶çå¬ï¼å½å ¶å¼ä¸º `true` æ¶ï¼`<foo>` å ç´ å°ä¼è¢«å建åè½½å ¥ï¼åä¹åä¸ä¼è¢«å建æ被移é¤æã -- `<foo repeat="...">` 代表ä¸ä¸ªå表çå¬ï¼ç¬¬ä¸æ¬¡å è½½çæ¶å `<foo>` å ç´ ä¼è¢«æç §æ°ç»éçæ°æ®éæ¡ clone 并èµå¼ãèå½æå表项å¢å ã移å¨æ移é¤æ¶ï¼è§å¾å±ä¹ä¼èªå¨è§¦åç¸åºçæ¹åï¼å¹¶ä¸æºè½ä¼åè³æå°åæ´çç¥ -- `<foo if="..." repeat="...">` 两个ç¹æ®è¯æ³å ±ç¨æ¶ï¼å°ä¼ä¼å å±å¼ `repeat` ç¶åéæ¡å¤æ `if`ã - -ç¸æ¯äºä¸äº virtual-DOM ç diff 计ç®æºå¶ï¼æ们ä¼ç´æ¥å¯¹æ°æ®è¿è¡ diffï¼èä¸åªä¼ diff ç±äºç¨æ·æä½ææ°æ®æä½åçæ¹åçé£é¨åæ°æ®åè§å¾ï¼è¿æ¯ä¸ç§æ´å°èå´ç计ç®æ¹å¼ãå°¤å ¶å¨è¿½æ±è½»éå¿«éç移å¨ç«¯çé¢ä¸ï¼è¿ç§æ´æ°æºå¶æ´å æ¾å¾å ·æä¼å¿ã http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/images/how-arch.png ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/images/how-arch.png b/doc/source/cn/v-0.10/advanced/images/how-arch.png deleted file mode 100644 index a13df7a..0000000 Binary files a/doc/source/cn/v-0.10/advanced/images/how-arch.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/images/how-render.png ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/images/how-render.png b/doc/source/cn/v-0.10/advanced/images/how-render.png deleted file mode 100644 index db9b0f4..0000000 Binary files a/doc/source/cn/v-0.10/advanced/images/how-render.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/8162f8c2/doc/source/cn/v-0.10/advanced/index.md ---------------------------------------------------------------------- diff --git a/doc/source/cn/v-0.10/advanced/index.md b/doc/source/cn/v-0.10/advanced/index.md deleted file mode 100644 index 8fea01e..0000000 --- a/doc/source/cn/v-0.10/advanced/index.md +++ /dev/null @@ -1,146 +0,0 @@ ---- -title: Weex å·¥ä½åç -type: advanced -order: 1 -has_chapter_content: true -version: 0.10 ---- - -# Weex å·¥ä½åçæ¦è¿° - -## æ»è§ - -Weexæ¯è·¨å¹³å°ï¼å¯æ©å±çå¨æåææ¯. ä½ è½éè¿å¨Weexæºç ä¸å`<template>`, `<style>` å `<script>`æ ç¾ï¼ç¶åæè¿äºæ ç¾è½¬æ¢ä¸ºJS Bundleç¨äºé¨ç½², å¨æå¡ç«¯ä»¥è¿äºJS Bundleååºè¯·æ±. å½å®¢æ·ç«¯æ¥æ¶å°JS Bundleæ¶ï¼å®è½ç¨è¢«å®¢æ·ç«¯ä¸çJSå¼æç¨äºç®¡çNative渲æ;APIè°ç¨åç¨æ·äº¤äº. - -### å·¥ä½æµ - -``` -Weex we æ件 --------------å端(weæºç ) -â (转æ¢) ------------------å端(æ建è¿ç¨) -JS Bundle -----------------å端(JS Bundle代ç ) -â (é¨ç½²) ------------------æå¡å¨ -å¨æå¡å¨ä¸çJS bundle ----æå¡å¨ -â (ç¼è¯) ------------------ 客æ·ç«¯(JSå¼æ) -èæ DOM æ --------------- 客æ·ç«¯(Weex JS Framework) -â (渲æ) ------------------ 客æ·ç«¯(渲æå¼æ) -Nativeè§å¾ --------------- 客æ·ç«¯(渲æå¼æ) -``` - -å¨ä¸é¢çå·¥ä½æµä¸ï¼æ们æå°: - -- Transformerï¼è½¬æ¢å¨): ä¸ä¸ªNode JSå·¥å ·ï¼ è½¬æ¢Weexæºç 为JS Bundle -- Weex JS Framework(JSæ¡æ¶): è¿è¡äºå®¢æ·ç«¯ççJSæ¡æ¶ï¼ç®¡ççWeexå®ä¾çè¿è¡ãWeexå®ä¾ç±JS Bundleå建并æ建起èæDOMæ . å¦å¤ï¼å®åé/æ¥å Native 渲æå±äº§ççç³»ç»è°ç¨ï¼ä»èé´æ¥çååºç¨æ·äº¤äºã -- Nativeå¼æ: å¨ä¸åç端ä¸ï¼æçä¸åçå®ç°: iOS/Android/HTML5. ä»ä»¬æçå ±åçç»ä»¶è®¾è®¡, 模åAPI å渲æææ. æ以ä»ä»¬è½é ååæ ·ç JS Framework å JS Bundleå·¥ä½ã - -## 转æ¢å¨ - -转æ¢å¨è½¬æ¢Weexæºç 为JS Bundle. æ´ä½å·¥ä½å¯ä»¥å为ä¸ä¸ªé¨å: - -- è½¬æ¢ `<template>` 为类JSONçæ ç¶æ°æ®ç»æ, 转æ¢æ°æ®ç»å®ä¸ºè¿åæ°æ®çå½æ°åå.ä¾å¦. For example: `<foo a="{% raw %}{{x}}{% endraw %}" b="1" />` å°è½¬æ¢ä¸º `{type: "foo", attr: {a: function () {return this.x}, b: 1}}`. -- è½¬æ¢ `<style>` 为类JSONçæ ç¶æ°æ®ç»æ. ä¾å¦: `.classname {name: value;}` å°è½¬æ¢ä¸º `{classname: {name: value}}`. -- æä¸é¢ä¸¤é¨åçå 容å `<script>` ä¸çå 容ç»å. ä¸é¢çä¸ä¸ªé¨åå°ç»åæä¸ä¸ªJavaScript AMD 模å. - -ä¸ä¸ªå®æ´çä¾å: - -```html -<template> - <foo a="{{x}}" b="1" class="bar"></foo> -</template> -<style> - .bar {width: 200; height: 200} -</style> -<script> - module.exports = { - data: function () { - return {x: 100} - } - } -</script> -``` - -å°è½¬æ¢ä¸º: - -```javascript -define('@weex-component/main', function () { - module.exports = { - data: function () { - return {x: 100} - } - } - module.template = { - type: "foo", - attr: { - a: function () {return this.x}, - b: 1, - classname: ['bar'] - } - } - module.style = { - bar: {width: 200, height: 200} - } -}) -bootstrap('@weex-component/main') -``` - -é¤æ¤ä¹å¤,转æ¢å¨è¿ä¼åä¸äºé¢å¤çäºæ : å并Bundle ,æ·»å å¼å¯¼å½æ°ï¼é ç½®å¤é¨æ°æ®ççï¼æ´è¯¦ç»çï¼è¯·åé [Synatax](../references/specs/js-bundle-format.html)ç« è. - -## 注æ - -å½å大é¨åWeexå·¥å ·æç»è¾åºçJS Bundleæ ¼å¼é½ç»è¿äº[Webpack](https://webpack.github.io/)çäºæ¬¡å¤çï¼æä»¥ä½ å®é 使ç¨å·¥å ·è¾åºçJS Bundleä¼åä¸é¢çææåºå«. -## JS Framework - -JS Framework å¨åå§åé¶æ®µè¢«åç JavaScript å¼æè¿è¡. å®æä¾è¢«æ¯ä¸ªJS Bundleè°ç¨ç `define()` å `bootstrap()` å½æ°. ä¸æ¦JS Bundleä»æå¡å¨ä¸è½½åï¼è¿äºå½æ°å°±ä¼æ§è¡. `define()` å½æ°ä»¥æ³¨å模å;`bootstrap()`ä¼ç¼è¯ä¸»è¦ç模å为èæDOMï¼å¹¶åé渲ææ令ç»Native . - -JS å Native çæ²é主è¦éè¿ä¸¤ä¸ªå ³é®æ¹æ³è¿è¡: - -- `callNative` æ¯ä¸ä¸ªç±native代ç å®ç°çå½æ°, å®è¢«JS代ç è°ç¨å¹¶ånativeåéæ令,ä¾å¦ `rendering`, `networking`, `authorizing`åå ¶ä»å®¢æ·ç«¯ä¾§ç `toast` çAPI. -- `callJS` æ¯ä¸ä¸ªç±JSå®ç°çå½æ°, å®ç¨äºNativeåJSåéæ令. ç®åè¿äºæ令ç±ç¨æ·äº¤äºåNativeçåè°å½æ°ç»æ. -## Native 渲æå¼æ - -Native 渲æå¼ææä¾å®¢æ·ç«¯ç»ä»¶å模å. - -**Component(ç»ä»¶)** å¨å±å¹å å¯è§ï¼æç¹å®è¡ä¸º. è½è¢«é ç½®ä¸åçå±æ§åæ ·å¼,è½ååºç¨æ·äº¤äº. 常è§çç»ä»¶æ: `<div>`, `<text>`, `<image>`. - -**Module(模å)** æ¯ä¸ç»è½è¢«JS Frameworkè°ç¨çAPI. å ¶ä¸çä¸äºè½ä»¥å¼æ¥çæ¹å¼è°ç¨JS Framework, ä¾å¦: åéHTTP请æ±. - -å¨Weexå®ä¾è¿è¡æé´,Native渲æå¼æå°æ¥æ¶åç§åæ ·ä¸å模åçAPIè°ç¨ãè¿äºè°ç¨å建ææ´æ°ç»ä»¶å¤è§ï¼è¿è¡å¦`toast`çNative API.å½ç¨æ·äº¤äºæ模ååè°æ¶ï¼`callJS()`ä¼ç±JS Frameworkè°ç¨. è¿æ ·ç循ç¯å¾å¤å°ä»Weexå®ä¾åå§åå°éæ¯ä¸ç´æç». å¦ä¸é¢çæ¶æå¾æ示, HTML5渲æå¼ææä¾åNative渲æå¼æå ä¹ä¸è´çåè½ã - -![arch](http://gtms02.alicdn.com/tps/i2/TB1ootBMpXXXXXrXXXXwi60UVXX-596-397.png) - -Weexæ¶æå¾ - -### ä»Javascriptä¸è°ç¨Native - -``` -[JS Framework] -â callNative -模å APIs - 渲æ -> 模åæ¾ç¤º - å ¶ä»åè½ -[Native 渲æå¼æ] -``` -### ä»Nativeä¸è°ç¨Javascript - -``` -[Native 渲æå¼æ] -模å APIs åè° -ç¨æ·äº¤äº -â callJS -[JS Framework] -``` -### 渲ææµç¨ - -![render flow](http://gtms03.alicdn.com/tps/i3/TB1_SA4MXXXXXXGaXXXpZ8UVXXX-519-337.png) - -Weex 渲ææµç¨ - -1. èæDOM. -2. **æé æ ç»æ**. åæèæDOM JSONæ°æ®ä»¥æé 渲ææ (RT). -3. **æ·»å æ ·å¼**. 为渲ææ çå个èç¹æ·»å æ ·å¼. -4. **å建è§å¾**. 为渲ææ å个èç¹å建Nativeè§å¾. -5. **ç»å®äºä»¶**. 为Nativeè§å¾ç»å®äºä»¶. -6. **CSSå¸å±**. ä½¿ç¨ [css-layout](https://github.com/facebook/css-layout) æ¥è®¡ç®å个è§å¾çå¸å±. -7. **æ´æ°è§çª(Frame)**. éç¨ä¸ä¸æ¥ç计ç®ç»ææ¥æ´æ°è§çªä¸å个è§å¾çæç»å¸å±ä½ç½®. -8. æç»é¡µé¢åç°. - -å¨Weex HTML5ç¯å¢ä¸ `CSS å¸å±` and `æ´æ°è§çª` ç±æµè§å¨å¼æ(ä¾å¦webkit)å®ç°.