weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sospar...@apache.org
Subject [19/39] incubator-weex-site git commit: * update site
Date Thu, 02 Mar 2017 03:54:11 GMT
http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/22906b6f/content/content.json
----------------------------------------------------------------------
diff --git a/content/content.json b/content/content.json
index 08860bf..1583541 100644
--- a/content/content.json
+++ b/content/content.json
@@ -1 +1 @@
-{"meta":{"title":"Weex","subtitle":null,"description":null,"author":"Jinjiang","url":"https://weex.apache.org"},"pages":[{"title":"Build A New App","path":"guide/dev-with-weexpack.html","permalink":"https://weex.apache.org/guide/dev-with-weexpack.html","text":"Build a New AppWork in progress.","type":"guide"},{"title":"Integrate to Your App","path":"guide/integrate-to-your-app.html","permalink":"https://weex.apache.org/guide/integrate-to-your-app.html","text":"Integrate to Your AppIntegrate to AndroidTip:The following documents assume that you already have a certain Android development experience. Android has tow ways to integrate weex1.using source code: Can quickly use the latest features of WEEX, according to your own characteristics of the project. So, you can do some related improvements. 2.using SDK: WEEX will regularly release a stable version at jcenter.jcenter PrerequisitesMake sure the following configuration is complete: JDK version >= 1.7 , and configure the environ
 ment variable Android SDK installed and configure the environment variable Android SDK version 23 (compileSdkVersion in build.gradle) SDK build tools version 23.0.1 (buildToolsVersion in build.gradle) Android Support Repository >= 17 (for Android Support Library) Quick to useIf you are the first time to try or have a higher demand for stability, you can use the way to dependence on the SDK.The steps are as follows: Create an Android project. There is nothing to be specified, according to your habits to. Update build.gradle by adding the following dependencies: compile 'com.android.support:recyclerview-v7:23.1.1'compile 'com.android.support:support-v4:23.1.1'compile 'com.android.support:appcompat-v7:23.1.1'compile 'com.alibaba:fastjson:1.1.46.android'compile 'com.taobao.android:weex_sdk:0.5.1@aar' Note: the version can be high can not be low. Start writing codeNote: There is a complete code address in the appendix Implement the picture download interface, set the initialization. p
 ackage com.weex.sample;import android.widget.ImageView;import com.taobao.weex.adapter.IWXImgLoaderAdapter;import com.taobao.weex.common.WXImageStrategy;import com.taobao.weex.dom.WXImageQuality;/*** Created by lixinke on 16/6/1.*/public class ImageAdapter implements IWXImgLoaderAdapter { @Override public void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy) { //To implement picture download interface, otherwise the picture can not be displayed. }} initialization package com.weex.sample;import android.app.Application;import com.taobao.weex.InitConfig;import com.taobao.weex.WXSDKEngine;/*** Note: add android:name=\".WXApplication\" into Manifest file* To implement ImageAdapter, otherwise the picture can not be downloaded* Gradle must add some dependencies, otherwise the initialization will fail.* compile 'com.android.support:recyclerview-v7:23.1.1'* compile 'com.android.support:support-v4:23.1.1'* compile 'com.android.support:a
 ppcompat-v7:23.1.1'* compile 'com.alibaba:fastjson:1.1.45'*/public class WXApplication extends Application { @Override public void onCreate() { super.onCreate(); InitConfig config=new InitConfig.Builder().setImgAdapter(new ImageAdapter()).build(); WXSDKEngine.initialize(this,config); }} Start rendering package com.weex.sample;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import com.taobao.weex.IWXRenderListener;import com.taobao.weex.WXSDKInstance;import com.taobao.weex.common.WXRenderStrategy;import com.taobao.weex.utils.WXFileUtils;public class MainActivity extends AppCompatActivity implements IWXRenderListener { WXSDKInstance mWXSDKInstance; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWXSDKInstance = new WXSDKInstance(this); mWXSDKInstance.registerRenderListener(this); /** * WXSample can be replaced by an
 y string * Template is js file that .we converted * Option can be empty, or through the option passed js required parameters. Such as the address of the bundle js. * JsonInitData can be empty. * width is -1 , default full screen, you can customize it. * height is -1 , default full screen, you can customize it. */ mWXSDKInstance.render(\"WXSample\", WXFileUtils.loadFileContent(\"hello.js\", this), null, null, -1, -1, WXRenderStrategy.APPEND_ASYNC); } @Override public void onViewCreated(WXSDKInstance instance, View view) { setContentView(view); } @Override public void onRenderSuccess(WXSDKInstance instance, int width, int height) { } @Override public void onRefreshSuccess(WXSDKInstance instance, int width, int height) { } @Override public void onException(WXSDKInstance instance, String errCode, String msg) { } @Override protected void onResume() { super.onResume(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityResume(); &#125
 ; } @Override protected void onPause() { super.onPause(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityPause(); } } @Override protected void onStop() { super.onStop(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityStop(); } } @Override protected void onDestroy() { super.onDestroy(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityDestroy(); } }} Dependence on source code (IDE Android Studio)1.Download source code. git clone https://github.com/alibaba/weex.2.Create an android project.3.Import the SDK Module through the following path:File->New-Import Module-> chose WEEX SDK Module(weex/android/sdk) -> Finish4.Add the following dependencies: compile project (‘: weex_sdk’) to build.gradle file.5.Other settings please refer to the above “Quick to use”. Appendix: WXSample address https://github.com/xkli/WXSample.git Integrated to iOSThrough the cocoaPods integrated Weex iOS SDK to the pro
 ject.First assume that you have finished installing the iOS development environment and CocoaPods. Step 1: Add DependenciesImport Weex iOS SDK to your existing project, if not, you can create a new project.Before proceeding, make sure that the Podfile file is under the project file. If not, create one and open with text editor. Integration framework WeexSDK The latest version on cocoaPods can be obtained here .Add the following to the Podfile file: source 'git@github.com:CocoaPods/Specs.git' target 'YourTarget' do platform :ios, '7.0' pod 'WeexSDK', '0.9.5' ## Suggest using latest Weex SDKend Integrate with source code First copy the ios / sdk directory to your existing project directory (here to copy the root directory of your existing project as an example), and then add the Podfile file. source 'git@github.com:CocoaPods/Specs.git' target 'YourTarget' do platform :ios, '7.0' pod 'WeexSDK', :p
 ath=>'./sdk/' end Step 2: Install DependenciesOpen the command line, switch to the directory of the Podfile file, and run the pod install command. If there are no errors, it means that the environment has been configured. Step 3: Initialize the Weex environmentIn the AppDelegate.m file to do the initialization operation, usually in the didFinishLaunchingWithOptions method as follows to add. //business configuration[WXAppConfiguration setAppGroup:@"AliApp"];[WXAppConfiguration setAppName:@"WeexDemo"];[WXAppConfiguration setAppVersion:@"1.0.0"];//init sdk enviroment [WXSDKEngine initSDKEnviroment];//register custom module and component,optional[WXSDKEngine registerComponent:@"MyView" withClass:[MyViewComponent class]];[WXSDKEngine registerModule:@"event" withClass:[WXEventModule class]];//register the implementation of protocol, optional[WXSDKEngine registerHandler:[WXNavigationDefaultImpl new] withProtocol:@protocol(WXN
 avigationProtocol)];//set the log level [WXLog setLogLevel: WXLogLevelAll]; Step 4: Render weex InstanceWeex supports both full page rendering and partial rendering. What you need to do is render Weex’s view with the specified URL and add it to its parent container. The parent container is generally a viewController. #import <WeexSDK/WXSDKInstance.h>- (void)viewDidLoad { [super viewDidLoad]; _instance = [[WXSDKInstance alloc] init]; _instance.viewController = self; _instance.frame = self.view.frame; __weak typeof(self) weakSelf = self; _instance.onCreate = ^(UIView *view) { [weakSelf.weexView removeFromSuperview]; [weakSelf.view addSubview:weakSelf.weexView]; }; _instance.onFailed = ^(NSError *error) { //process failure }; _instance.renderFinish = ^ (UIView *view) { //process renderFinish }; [_instance renderWithURL:self.url options:@{@"bundleUrl":[self.url absoluteString]} data:nil];} WXSDKInstance is a very import
 ant class that provides a basic method and some callbacks, such as renderWithURL, onCreate, onFailed, etc., can be found in WXSDKInstance.h. Step 5: Destroy Weex InstanceIn the dealloc phase of the viewController destroyed Weex instance, can play a role in avoiding memory leaks. - (void)dealloc{ [_instance destroyInstance];} Import the Weex SDK framework to the project.The Weex SDK can be compiled from the source code. You can try the latest feature in the new feature or bugfix branch.Refer to here for direct import of weexSDK.","type":"guide"},{"title":"Android APIs","path":"references/android-apis.html","permalink":"https://weex.apache.org/references/android-apis.html","text":"Android APIsWXSDKEngine Set up various adapters WXSDKEngine.initialize(this, new InitConfig.Builder().setImgAdapter(new ImageAdapter()).setDebugAdapter(new PlayDebugAdapter()).build()); Register the module and component WXSDKEngine.registerComponent(\"richtext\", RichText.class);WXSDKEngine.registe
 rModule(\"event\", WXEventModule.class); Overloading framework WXSDKEngine.reload(this,framework,false); Adapter IWXImgLoaderAdapter Weex need to implement this interface to download the pictureThe interface is defined as follows: public interface IWXImgLoaderAdapter { void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);} WXImageQuality that the quality of the picture variables, take the following values LOW, NORMAL, HIGH, ORIGINAL picture quality in turn higher. The default is LOW. WXImageStrategy is an extension class that indicates whether the image can be cut (isClipping) sharpening (isSharpen) placeholder (placeHolder) and so on. IWXHttpAdapter Weex custom WXRequest and OnHttpListener, Native reload interface can be obtained from the Request URL, Header and other parameters, the network request can be completed through OnHttpListener callback notification. Weex provides the default network request: DefaultWXHttpAdapter, using Ht
 tpURLConnection for network requests. The interface is defined as follows: public interface IWXHttpAdapter { void sendRequest(WXRequest request, OnHttpListener listener);} WXRequest defines the parameters related to the network request, the request method, the request body, and the timeout time. Weex default timeout is 3000. OnHttpListener defines the corresponding method after the network request ends. Defined as follows: interface OnHttpListener { /** * start request */ void onHttpStart(); /** * headers received */ void onHeadersReceived(int statusCode,Map<String,List<String>> headers); /** * post progress * @param uploadProgress */ void onHttpUploadProgress(int uploadProgress); /** * response loaded length (bytes), full length should read from headers (content-length) * @param loadedLength */ void onHttpResponseProgress(int loadedLength); /** * http response finish * @param response */ void onHttpFinish(WXResponse response); } IWXUserTrackAdapter W
 eex related performance data (first screen loading time, JS-Native communication time, dom update time, etc.) and other general information (JSLib file size, Weex SDK version number, etc.).Interface definition: public interface IWXUserTrackAdapter { void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);} Native implementation interface can be obtained through WXPerformance and params corresponding information. Native interacts with JavaScriptCustom eventsUsed for a custom control for event notifications, such as custom click events, response drop events, and so on. WXSDKInstance.java public void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges){ }public void fireEvent(String elementRef,final String type, final Map<String, Object> data){ fireEvent(elementRef,type,data,null);}public void fireEvent(String eleme
 ntRef, String type){ fireEvent(ref,type,new HashMap<String, Object>());} elementRef:The event occurred for the control ID。 type: Custom events, Weex defaults to a custom event starting with onXxxxx. OnPullDown (drop-down event) data: Need to reveal the parameters, such as the current control of the size, coordinates and other information。 domChanges:Update ref for the control’s Attribute and Style Event callbackUsed for Module callback, for example, after the completion of positioning Module need to notify JS. Use as follows: public class WXLocation extends WXModule { @JSMethod public void getLocation(JSCallback callback){ //Get the code for the location information ..... Map<String,String> data=new HashMap<>(); data.put(\"x\",\"x\"); data.put(\"y\",\"y\"); //notify once callback.invoke(data); //Continuous connection callback.invokeAndKeepAlive(data); //Invoke method and invokeAndKeepAlive two methods of choice }} OnWXScrollL
 istenerWeex gets the scroll event You can register registerOnWXScrollListener via WXSDKInstanceThe interface is defined as follows: public interface OnWXScrollListener { /** * The view is not currently scrolling. */ int IDLE = RecyclerView.SCROLL_STATE_IDLE; /** * The view is currently being dragged by outside input such as user touch input. */ int DRAGGING = RecyclerView.SCROLL_STATE_DRAGGING; /** * The view is currently animating to a final position while not under * outside control. */ int SETTLING = RecyclerView.SCROLL_STATE_SETTLING; /** * Callback method to be invoked when the view has been scrolled. This will be * called after the scroll has completed. * <p> * This callback will also be called if visible item range changes after a layout * calculation. In that case, dx and dy will be 0. * */ void onScrolled(View view, int x, int y); /** * Callback method to be invoked when view's scroll state changes. * */ void onScrollStateChanged(View view, int x, int y, int newS
 tate);} IActivityNavBarSetterWeex provides WXNavigatorModule for navigation control, and the corresponding method can be customized by setting the IActivityNavBarSetter interface. Instructions: WXSDKEngine.setActivityNavBarSetter(new IActivityNavBarSetter(){}); Other IntroductionsetSizeYou can use the mWXSDKInstance.setSize() method to change the size of the Weex container. DowngradeWeex in the development stage will add some new features and new methods, but these new features and functions must be upgraded to achieve the SDK, for the application should not be upgraded how to deal with it? You can use the downgrade feature. Native can be handled by the onException method in interface IWXRenderListener, and if it is an active demoulding errCode is a character that is divided by “|”. “|” The preceding character is 1 for active demotion, and the Native side can jump to the corresponding H5 page. Or otherwise prompted the user’s current environment does not sup
 port Weex.","type":"references"},{"title":"Color name","path":"references/color-names.html","permalink":"https://weex.apache.org/references/color-names.html","text":"List of the names of colorsBasic color keywords: Color Name Hex rgb black #000000 silver #C0C0C0 gray #808080 white #FFFFFF maroon #800000 red #FF0000 purple #800080 fuchsia #FF00FF green #008000 lime #00FF00 olive #808000 yellow #FFFF00 navy #000080 blue #0000FF teal #008080 aqua #00FFFF Extended color keywords: Color Name Hex rgb aliceblue #F0F8FF antiquewhite #FAEBD7 aqua #00FFFF aquamarine #7FFFD4 azure #F0FFFF beige #F5F5DC bisque #FFE4C4 black #000000 blanchedalmond #FFEBCD blue #0000FF blueviolet #8A2BE2 brown #A52A2A burlywood #DEB887 cadetblue #5F9EA0 chartreuse #7FFF00 chocolate #D2691E coral #FF7F50 cornflowerblue #6495ED cornsilk #FFF8DC crimson #DC143C cyan #00FFFF darkblue #00008B darkcyan #008B8B darkgoldenrod #B8860B darkgray #A9A9A9 darkgreen #006400 darkgrey #A9A9A9 darkkhaki #BDB76B darkmagenta #8B008
 B darkolivegreen #556B2F darkorange #FF8C00 darkorchid #9932CC darkred #8B0000 darksalmon #E9967A darkseagreen #8FBC8F darkslateblue #483D8B darkslategray #2F4F4F darkslategrey #2F4F4F darkturquoise #00CED1 darkviolet #9400D3 deeppink #FF1493 deepskyblue #00BFFF dimgray #696969 dimgrey #696969 dodgerblue #1E90FF firebrick #B22222 floralwhite #FFFAF0 forestgreen #228B22 fuchsia #FF00FF gainsboro #DCDCDC ghostwhite #F8F8FF gold #FFD700 goldenrod #DAA520 gray #808080 green #008000 greenyellow #ADFF2F grey #808080 honeydew #F0FFF0 hotpink #FF69B4 indianred #CD5C5C indigo #4B0082 ivory #FFFFF0 khaki #F0E68C lavender #E6E6FA lavenderblush #FFF0F5 lawngreen #7CFC00 lemonchiffon #FFFACD lightblue #ADD8E6 lightcoral #F08080 lightcyan #E0FFFF lightgoldenrodyellow #FAFAD2 lightgray #D3D3D3 lightgreen #90EE90 lightgrey #D3D3D3 lightpink #FFB6C1 lightsalmon #FFA07A lightseagreen #20B2AA lightskyblue #87CEFA lightslategray #778899 lightslategrey #778899 lightsteelblue #B0C4DE lightyellow #FFFFE0 
 lime #00FF00 limegreen #32CD32 linen #FAF0E6 magenta #FF00FF maroon #800000 mediumaquamarine #66CDAA mediumblue #0000CD mediumorchid #BA55D3 mediumpurple #9370DB mediumseagreen #3CB371 mediumslateblue #7B68EE mediumspringgreen #00FA9A mediumturquoise #48D1CC mediumvioletred #C71585 midnightblue #191970 mintcream #F5FFFA mistyrose #FFE4E1 moccasin #FFE4B5 navajowhite #FFDEAD navy #000080 oldlace #FDF5E6 olive #808000 olivedrab #6B8E23 orange #FFA500 orangered #FF4500 orchid #DA70D6 palegoldenrod #EEE8AA palegreen #98FB98 paleturquoise #AFEEEE palevioletred #DB7093 papayawhip #FFEFD5 peachpuff #FFDAB9 peru #CD853F pink #FFC0CB plum #DDA0DD powderblue #B0E0E6 purple #800080 red #FF0000 rosybrown #BC8F8F royalblue #4169E1 saddlebrown #8B4513 salmon #FA8072 sandybrown #F4A460 seagreen #2E8B57 seashell #FFF5EE sienna #A0522D silver #C0C0C0 skyblue #87CEEB slateblue #6A5ACD slategray #708090 slategrey #708090 snow #FFFAFA springgreen #00FF7F steelblue #4682B4 tan #D2B48C teal #008080 thist
 le #D8BFD8 tomato #FF6347 turquoise #40E0D0 violet #EE82EE wheat #F5DEB3 white #FFFFFF whitesmoke #F5F5F5 yellow #FFFF00 yellowgreen #9ACD32","type":"references"},{"title":"Common Events","path":"references/common-event.html","permalink":"https://weex.apache.org/references/common-event.html","text":"Common EventsWeex provide the ability to let events trigger action, like starting a JavaScript when a user click on a component. Bellow are the common event attributes that can be added to weex components to define event actions. Click eventThe onclick attribute fires on a click gesture on the element.Notes: The input and switch component does not currently support the click event, please use change or input event instead. event object type : click target : The target component where the event is triggered timestamp : Timestamp when event is triggered Longpress eventIf a longpress event is bound to a component, the event will be triggered when user long press on it.Notes: The input and s
 witch component does not currently support the click event, please use change or input event instead. event object type : longpress target : The target component where the event is triggered timestamp : Timestamp when event is triggered Appear eventIf a appear event is bound to a component inside a scrollable container, the event will be triggered when the component comes to be visible. event object type : appear target : The target component where the event is triggered timestamp : Timestamp when event is triggered direction : The direction in which the scroller is scrolling. Could be up or down. Disappear eventIf a disappear event is bound to a component inside a scrollable container, the event will be triggered when the component scrolls out of viewport and disappears from your sight. event object type : disappear target : The target component where the event is triggered timestamp : Timestamp when event is triggered direction : The direction in which the scroller is scrolling. C
 ould be up or down. Page eventWeex provides you with simple management of page status, such as viewappear and viewdisappear.The viewappear event will be triggered when page is about to show or before any animations are configured for showing. For example, when calling push method in navigator module, this event will be trigged in new page.The viewdisappear event will be triggeded when page is about to dismiss.Different from appear and disappear of component, these two events focus on the status of whole page, so they must be bound to the root component.In addititon, these events also can be bound to body component which is not root actually such as wxc-navpage. event object type : viewappear or viewdisappear target : The target component where the event is triggered timestamp : Timestamp when event is triggered Example<template> <div> <div class=\"box\" @click=\"onclick\" @longpress=\"onlongpress\" @appear=\"onappear\" @disappear=\"ondisappear\"></div> </d
 iv></template><script> const modal = weex.requireModule('modal') export default { methods: { onclick (event) { console.log('onclick:', event) modal.toast({ message: 'onclick', duration: 0.8 }) }, onlongpress (event) { console.log('onlongpress:', event) modal.toast({ message: 'onlongpress', duration: 0.8 }) }, onappear (event) { console.log('onappear:', event) modal.toast({ message: 'onappear', duration: 0.8 }) }, ondisappear (event) { console.log('ondisappear:', event) modal.toast({ message: 'ondisappear', duration: 0.8 }) } } }</script><style scoped> .box { border-width: 2px; border-style: solid; border-color: #BBB; width: 250px; height: 250px; margin-top: 250px; margin-left: 250px; background-color: #EEE; }</style>","type":"references"},{"title":"Common Style","path":"references/common-style.html","permalink":"https://weex.apache.org/refere
 nces/common-style.html","text":"Common StyleAll of weex tags share some common style rules Box Model Weex box model based on the CSS box model, all of weex elements can be considered as boxes. The term “box model” is used when talking about design and layout. The box model is essentially a box that wraps around every HTML element. It consists of margins, borders, paddings, and the actual content. you can use the definition below in weex box model. width: length type, default value 0 height: length type, default value 0 padding: length type, default value 0, (space around content, between element content and the element border) padding-left: length type, default value 0 padding-right: length type, default value 0 padding-top: length type, default value 0 padding-bottom: length type, default value 0 margin: length type, default value 0, (space around elements, outside the border) margin-left: length type, default value 0 margin-right: length type, default value 0 margin-top: lengt
 h type, default value 0 margin-bottom: length type, default value 0 border border-style: values solid | dashed | dotted, default value solid border-left-style: values solid | dashed | dotted, default value solid border-top-style: values solid | dashed | dotted, default value solid border-right-style: values solid | dashed | dotted, default value solid border-bottom-style: values solid | dashed | dotted, default value solid border-width: length type, non-negative, default value 0DO NOT use border-width:1. There is a default viewport <viewport width="750">, if the actual width of a device is 720px, then border-width:1 will be border-width:0.96. As weex do not support sub-pixel, this border would not be rendered. border-left-width: length type, non-negative, default value 0 border-top-width: length type, non-negative, default value 0 border-right-width: length type, non-negative, default value 0 border-bottom-width: length type, non-negative, default value 0 border-colo
 r: color type, default value #000000 border-left-color: color type, default value #000000 border-top-color: color type, default value #000000 border-right-color: color type, default value #000000 border-bottom-color: color type, default value #000000 border-radius: length type, default value 0, (rounded borders to elements , default value is 0 meaning right angle ) Although the the default overflow style is overflow:hidden in android, a view will not be clipped by its parents’ border-radius. This only happens on Android, it works fine on iOS. border-bottom-left-radius: length type, non-negative, default value 0 border-bottom-right-radius: length type, non-negative, default value 0 border-top-left-radius: length type, non-negative, default value 0 border-top-right-radius: length type, non-negative, default value 0 Notes: The rule of border-radius for a specific corner such as border-top-left-radius is not currently supported for component <image> and <text>. Weex box mo
 del uses border-box as the default value of box-sizing, meaning the width and height properties includes content, padding and border, but not the margin. example: <template> <div> <image src=\"...\" style=\"width: 400; height: 200; margin-left: 20;\"></image> </div></template> FlexboxWeex box style model based on the CSS flexbox, ensures that elements behave predictably and the page layout can accommodates to different screen sizes and different display devices. Flexbox consists of flex containers and flex items. If a weex element can containing other elements, it is a flex container. Notice that the old version of flexbox specification has differences with the new ones, such as whether or not to support wrapping. This is described at w3c’s working drafts, and you should notice the differences among them. Also notice that the old version is only supported below the 4.4 version of android. Flex containerFlexbox is the default and only style model
  in Weex, so you don’t have to add display: flex; in a container. flex-direction: values row | column, default value column The flex-direction property specifies the direction of the flexible items inside the flex container. Default value is column (top-to-bottom). justify-content: values flex-start | flex-end | center | space-between, default value flex-start The justify-content property horizontally aligns the flexible container’s items when the items do not use all available space on the main-axis. Default value is flex-start meaning the flex items are positioned at the beginning of the container. flex-end means the items are positioned at the end of the container. center means the items are positioned at the center of the container. space-between means the items are positioned with space between the lines. align-items: values stretch | flex-start | center | flex-end, default value stretch The align-items property vertically aligns the flexible container’s items when the it
 ems do not use all available space on the cross-axis. Default value is stretch meaning the items are stretched to fit the container. flex-start means the items are positioned at the top of the container; flex-end means the items are positioned at the bottom of the container; center means items are positioned at the center of the container (vertically). Flex item flex: number type, default value 0 the flex property specifies the length of the flex item, relative to the rest of the flex items inside the same container. If all of the flex items set flex: 1, they will have equal width or height on direction of flex container’s flex-direction. If there are two flex items, with one setting flex: 1, and the other setting flex: 2, the first one will take 1/3 container space, and the second one will take 2/3 container space. If all of flex items don’t set flex, they will be aligned depending on the container’s justify-content property. Examplesa list of images with equal scales align a
 t the vertical axis: <template> <div style=\"width: 300; height: 100;\"> <image src=\"...\" style=\"flex: 1;\"></image> <image src=\"...\" style=\"flex: 1;\"></image> <image src=\"...\" style=\"flex: 1;\"></image> </div></template> a image with fixed width aligns with a stretched text: <template> <div style=\"width: 300; height: 100;\"> <image src=\"...\" style=\"width: 100; height: 100;\"></image> <text style=\"flex: 1;\">...</text> </div></template> mixed direction alignment: <template> <div style=\"width: 100;\"> <image src=\"...\" style=\"width: 100; height: 100;\"></image> <div style=\"flex-direction: row;\"> <text style=\"flex: 2; font-size: 32;\">title</text> <text style=\"flex: 1; font-size: 16;\">$100</text> </div> </div></template> one text align left , the other float right: <template><
 div style=\"flex-direction: row; justify-content: space-between;\"> <text>WEEX</text> <text>2016-05-08</text></div></template> Positionwe can use properties below to control placement of weex tag position: values relative | absolute | fixed | sticky, default value relative relative means the item is positioned relative to its normal position. absolute means the item is positioned relative to its container. fixed keeps the elements position fixed when the page is scrolling. sticky keeps elements positioned inside the viewport as “stuck” at the top or “relative” at its original place depending on whether does it about to scroll out of the view. top: number type, default value 0, upward offset value bottom: number type, default value 0, downward offset value left: number type, default value 0, leftward offset value right: number type, default value 0, rightward offset value Examples<template> <div style=\"flex-direction: column;\"
 > <div style=\"height: 3000;\"> <image src=\"...\" style=\"top: 50px; left: 50px;\"></image> </div> <div style=\"height: 3000;\"> <image src=\"...\" style=\"position: sticky;\"></image> </div> <div style=\"height: 3000;\"> <image src=\"...\" style=\"position: absolute; top: 50px; left: 50px;\"></image> </div> </div></template> Pseudo class v0.9.5+Weex support four pseudo-classes: active, focus, disabled, enabled All components support active, but only the input component and the textarea component support focus, enabled, diabled. Rule the high priority override low priority when rules take effect at the same time such as: “input:active:enabled” will override “input:active” the interconnection rule as follow Example<template> <div class=\"wrapper\"> <image :src=\"logoUrl\" class=\"logo\"></image> </div></template><style scoped> .wrapper { align
 -items: center; margin-top: 120px; } .title { font-size: 48px; } .logo { width: 360px; height: 82px; background-color: red; } .logo:active { width: 180px; height: 82px; background-color: green; }</style><script> export default { props: { logoUrl: { default: 'https://alibaba.github.io/weex/img/weex_logo_blue@3x.png' }, target: { default: 'World' } }, methods: { update (e) { this.target = 'Weex'; } } };</script> Try it linear-gradient v0.10+Weex support linear-gradient background, You can see W3C description of the gradient. Supported componentsAll components in Weex support gradients UsageYou can use linear gradient by background-image property. background-image: linear-gradient(to top,#a80077,#66ff00); radial-gradient is not currently supported, do not use it. Weex currently supports two color gradients. The direction of the gradient is as follows: to rightFrom left to ri
 ght to leftFrom right to left to bottomFrom top to bottom to topFrom bottom to top to bottom rightFrom the upper left corner to the lower right corner to top leftFrom the lower right corner to the upper left corner Note background-image and background-color are set at the same time, background-image precedes background-color. Do not use shorthand property such as background. Example<template> <scroller style=\"background-color: #3a3a3a\"> <div class=\"container1\" style=\"background-image:linear-gradient(to right,#a80077,#66ff00);\"> <text class=\"direction\">to right</text> </div> <div class=\"container1\" style=\"background-image:linear-gradient(to left,#a80077,#66ff00);\"> <text class=\"direction\">to left</text> </div> <div class=\"container1\" style=\"background-image:linear-gradient(to bottom,#a80077,#66ff00);\"> <text class=\"direction\">to bottom</text> </div> <div class=\"container1\" sty
 le=\"background-image:linear-gradient(to top,#a80077,#66ff00);\"> <text class=\"direction\">to top</text> </div> <div style=\"flex-direction: row;align-items: center;justify-content: center\"> <div class=\"container2\" style=\"background-image:linear-gradient(to bottom right,#a80077,#66ff00);\"> <text class=\"direction\">to bottom right</text> </div> <div class=\"container2\" style=\"background-image:linear-gradient(to top left,#a80077,#66ff00);\"> <text class=\"direction\">to top left</text> </div> </div> </scroller></template><style> .container1 { margin: 10px; width: 730px; height: 200px; align-items: center; justify-content: center; border: solid; border-radius: 10px; } .container2 { margin: 10px; width: 300px; height: 300px; align-items: center; justify-content: center; border: solid; border-radius: 10px; } .direction { font-size: 40px; color: white; &#125
 ;</style> Other Common Style opacity background-color Type of Style Value length type number type color type (The list of color keywords.) enumerated type Simple StepThese up-to-down steps may help you to plan the whole style of weex pages. overall style: divide the whole page to different parts flex alignment: align boxes in every part of page position box: place box, set offset element specific style: set styles for certain element if needed","type":"references"},{"title":"Gesture","path":"references/gesture.html","permalink":"https://weex.apache.org/references/gesture.html","text":"Gesture Experiment Feature Weex encapsulates native touch events to provide a gesture system. Using gesture is similar to use event in Weex. Just set on attributes on a node to listen to gesture. TypeFor now, there are four types of gestures: Touch. Touch gesture is fired when a touch point is placed, moved or removed from the touch surface. Touch gesture is accuracy as it will report every trivi
 al event. As a result, listening to touch gesture may be slow, a great deal of events needs to be processed even a small move happened. There are three types of Touch gesture: touchstart will be fired when a touch point is placed on the touch surface. touchmove will be fired when a touch point is moved along the touch surface. touchend will be fired when a touch point is removed from the touch surface. Pan. Pan gesture also report motion of touch point on the touch surface, which is similar to touch gesture. But Pan gesture is sampled and faster than the touch event. As consequence, it is less accuracy than touch gesture. There are also three types of Pan gesture, and the meaning of these types is very close to types of Touch. panstart panmove panend Horizontal/Vertical Pan v0.10+ . Mainly used for cell swipe gestures before conflict resolving system is completed. start/move/end state of the gesture will be passed by state property. Note: These gestures are in conflict with click ev
 ent on Android currently. horizontalpan verticalpan Swipe. Swipe is fired when user swipe a touch point on the screen. A serial of motion will only trigger one Swipe gesture. LongPress. Swipe is fired when a touch point is held for 500 ms or more. The Touch gesture and Pan is very close to each other, with following features hold: Touch. Not sampled, accuracy, but slow. Pan. Sampled, fast, less accuracy. Users may choose their gesture according to their situation. PropertiesThe following properties can be used in gesture callback: direction. Only exists for Swipe gesture. Indicate the direcion of the swipe, choose from up, left, bottom, right. changedTouches. An array of motion for every touch pointer that has contribute to the current gesture. changedToucheschangedTouches is an array, with the following properties in its children: identifier. A unique identifier for a touch pointer. pageX. The X coordinate of the touch pointer relative to the left edge of the document. pageY. The Y
  coordinate of the touch pointer relative to the top of the document. screenX. The X coordinate of the touch point relative to the left edge of the screen. screenY. The Y coordinate of the touch point relative to the top edge of the screen. ConstrainCurrently, Weex Android do not support listening to gesture on scroller, list and webview, as it would lead a large amount of event conflicting.","type":"references"},{"title":"HTML5 APIs","path":"references/html5-apis.html","permalink":"https://weex.apache.org/references/html5-apis.html","text":"HTML5 APIsVue APIs","type":"references"},{"title":"iOS APIs","path":"references/ios-apis.html","permalink":"https://weex.apache.org/references/ios-apis.html","text":"iOS APIsHandler(like Android Adapter) WXImgLoaderDefaultImpl Image load handler. Weex need to implement this interface to download the picture. The interface is defined as follows: @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 Native interacts with JavaScript Custom events Used for a custom control for event notifications, such as custom click events, response drop events, and so on. This is a method in the component base class that can be used directly. /** * @abstract Fire an event to the component and tell Javascript which value has bee
 n changed. * @param eventName * @param params * @param domChanges **/- (void)fireEvent:(NSString *)eventName params:(NSDictionary *)params domChanges:(NSDictionary *)domChanges Event callback Used for Module callback. There are two types of callback: WXModuleCallback: For performance reasons, the callback can only callback js once, and then will be released. WXModuleKeepAliveCallback: This callback can be set to multiple callbacks, multiple callbacks of the scene such as continually listen scrolls event and return to js. @implementation WXEchoModule@synthesize weexInstance;WX_EXPORT_METHOD(@selector(echo:))- (void)echo:(NSString *)param callback:(WXModuleKeepAliveCallback)callback{ callback(param,ture);} Set size of the Weex containerYou can use the setFrame(CGRect) method to change the size of the Weex container. DowngradeWeex in the development stage will add some new features and new methods, but these new features and functions must be upgraded to achieve the SDK, for 
 the application should not be upgraded how to deal with it? You can use the downgrade feature. Native can be handled by the onFailed method in interface WXSDKInstance, and if it is an active demoulding error domain is TemplateErrorType, and the Native side can jump to the corresponding H5 page. Or otherwise prompted the user’s current environment does not support Weex.","type":"references"},{"title":"JS Framework APIs","path":"references/jsfm-apis.html","permalink":"https://weex.apache.org/references/jsfm-apis.html","text":"JS Framework APIsBroadcastChannel v0.9+BroadcastChannel API is the solution for inter-instance communication. Reference BroadcastChannel specification. MessageEvent specification API postMessage(message): Sends the given message to other BroadcastChannel objects set up for this channel. close: Closes the BroadcastChannel object, opening it up to garbage collection. onmessage: Event handler, the event will be triggered when the instance receive a message. Usagec
 onst Stack = new BroadcastChannel('Avengers')Stack.onmessage = function (event) { console.log(event.data) // in this case, it's \"Hulk Smash !!!\"}// in another instanceconst Hulk = new BroadcastChannel('Avengers')Hulk.postMessage(\"Hulk Smash !!!\") Run the code above, Stack can receive the message from Hulk. NoticeOne thing should be noticed: The message object is not deep cloned. See the demo below: const a = new BroadcastChannel('app')const b = new BroadcastChannel('app')const message = { lists: ['A', 'B']}a.onmessage = function (event) { // in this case, event.data is a reference of message console.assert(event.data === message)}b.postMessage(message) In this case, event.data is strict equal to message. Compared to the deep clone, this behavior improves efficiency and reduces memory cost. However, developers are not recommended to cache or modify the event object when they are using it (All type of event handlers should have this restriction).","ty
 pe":"references"},{"title":"Path","path":"references/path.html","permalink":"https://weex.apache.org/references/path.html","text":"Path0.9 This article will cover uri (url) usage in Weex. Including using image/typeface resources, deal with relative uri and how to access local and packaged asset files. Schemes LocalWeex SDK provide local scheme to access resources packaged with application, and of cource, it’s not working in the HTML5 runtime.Currently, developers can use this scheme with image and text’s font file location. In iOS, it’s always locate file in ‘bundle resources’. For example, a image component with local:///app_icon will load image file named ‘app_icon’ in bundle resouce, and font file work in the same way. In Android, image component will load from ‘drawable’ resource folder like ‘res/drawable-xxx’. But load font file is different, android framework can not load font file from ‘res’, so SDK will load it from asserts folder. HTTP/HTTPSIt’s 
 working in the same way as in web, Weex support these at very beginning. FileUse file scheme to access local disk file. This scheme has its limitations: You would not hard coded a file url in source page. Because not matter it’s running in different platform(iOS, Android) or not, the content will be totally different in another device, which is depend to the specific device.So one possible case is getting the file url in runtime dynamically, which you can use it to diaplay a local disk image, or maybe upload it later. Relative URILike we do in HTML, weex process ‘relative URI’ in the same way. The relative URI, which start with /,.,..,//, will resolve by the bunle url.Means URL start with / will resolve to the root folder as bundle js file, . and .. will resolve to current and parent folder, and // will resolve to same scheme bundle js have. URI AdapterAll the above is the default implementation, developers can extend or override these their own by providing a ‘URI Adapter
 . Same as the other adapters, Custom adapter should be set before Weex SDK is initializing.","type":"references"},{"title":"Platform Differences Between Weex and Web","path":"references/platfrom-difference.html","permalink":"https://weex.apache.org/references/platfrom-difference.html","text":"Platform Differences Between Weex and WebWork in progresss.","type":"references"},{"title":"Text Style","path":"references/text-style.html","permalink":"https://weex.apache.org/references/text-style.html","text":"Text StyleText alike components share some common style rules. The text alike components currently includes text and input. Properties color: <colors> this property set the foreground color of an component’s text content. font-size: <length> this property specifies the size of the font. font-style: <enum> normal | italic. This property lets you select italic or normal faces within a font-family. Default value is normal. font-weightv0.9+: values: normal, bold, 100, 
 200, 300, 400, 500, 600, 700, 800, 900 normal is equal to 400, bold equel to 700 default value: normal apply to: <text>, <input> ios support showing 9 kind of font-weight. android support showing 2 kind of font-weight:400,700, other value will map to 400 or 700 Some standard values like lighter, bolder, number unit are not supported. The effect not apply to all elements, just <text> and <input>. In another way, it’s not inherited. text-decoration: <enum> none | underline | line-through. This property is used to set the text formatting to underline or line-through. The default value is none. text-align: <enum> left | center | right. This property describes how inline content like text is aligned in its parent component. The default value is left. font-family:<string> this property set the font-family of the text. This property doesn’t guarantee the given font will always be set to the text. If the specified font cannot be found at the dev
 ice, a typeface fallback will occur and the default typeface will be load. The fallback mechanism may vary in different devices. text-overflow:<string> clip | ellipsis. This property determines how overflowed content that is not displayed is signaled to users. It can be clipped, display an ellipsis. The property color support multiple fomats of values, contains rgb, rgba, #fff, #ffffff, named-color. Example: .my-class { color: red; }.my-class { color: #f00; }.my-class { color: #ff0000; }.my-class { color: rgb(255, 0, 0); }.my-class { color: rgba(255, 0, 0, 0.5); } Type of Style Value length: number followed by length unit px, px can be omitted. colors: support multiple formats of values, including rgb (rgb(255, 0, 0)), rgba (rgba(255, 0, 0, 0.5)), hexadecimal (#ff0000), short hexadecimal (#f00), named color (red). enumerated values: a limited number of string values. Note: The list of color keywords.","type":"references"},{"tit
 le":"CSS unit","path":"references/unit.html","permalink":"https://weex.apache.org/references/unit.html","text":"CSS unitWork in progresss.","type":"references"},{"title":"Native DOM APIs","path":"references/native-dom-api.html","permalink":"https://weex.apache.org/references/native-dom-api.html","text":"Native DOM APIsWeex in the JS engine, for each page provides a set of Native DOM APIs. This interface is very close to the HTML DOM APIs. Using this interface we can control native rendering logic via JavaScript. And Weex upper layer of Vue 2.0 is based on this interface to adapt. In most cases, the JS framework will encapsulate native DOM APIs. That way, the developer does not need to work directly on the Native DOM. Document class: full page document. Node class: the base class of nodes. Element class: element node, inherited from Node, single view unit. Comment class: comment node, inherited from Node, no practical meaning, usually used as placeholders. Each Weex page has a weex.d
 ocument object, which is an instance of the Document class and is the starting point for all the following interface calls. Let’s take a look at their usage in detail: Document classEach Document instance will automatically have a documentElement property when it is created. This attribute represents the document node. The document node can have a body, which is the main node of the document. Note: The document node body only accepts <div>, <list>, or <scroller> three types of element nodes. Constructornew Document(id: string, url: string?) Member methodcreateElement(tagName: string, props: Object?): Element Creates an Element instance of a specific type tagName, which is an element node. Props can contain attr objects and style objects. Such as createBody ('div', {style: {backgroundColor: '#ffffff'}}). createComment(text: string): Comment Create an instance of ·Comment, which is a comment node and set a text description. createBody(tagName: stri
 ng, props: Object?): Element Create a document body node and automatically mount it under documentElement. fireEvent(el: Element, type: string, e: Object?, domChanges: Object?)Triggers a particular type of event. When the event modifies the DOM’s properties or styles during the generation process, the fourth argument is used to describe the changes, and the parameter format is the same as the format of the createElement method above. destroy() Destroy the current document. Once the document is destroyed, it will no longer work. Read-only member variablesid: string Each Document instance has a unique id. This is also the only id that each Weex page has. URL: string? If the current Weex page has a JS bundle URL, the URL will be returned here. body: Element The main body of the document, the concept similar to the HTML DOM document.body. documentElement: Element Document node, the concept similar to the HTML DOM document.documentElement. The relationship between body and documentElem
 ent is: documentElement is the parent of the body. getRef(id): Node Get the node based on the node id. Node ClassConstructornew Node() Member methoddestroy() Read-only member variables or methodsref: string Each Node instance has its own unique ref value in the entire `Document instance. nextSibling: Node? previousSibling: Node? parentNode: Node? The three interfaces are consistent with the definition of HTML DOM. children: Node[] The node has an array of all child nodes. pureChildren: Node[] The node has an array of all the child elements. The difference between it and children is that pureChildren contains only the Element instance and not the Comment instance. Element class, inherited from NodeConstructornew Element(type: string, props: Object?) Creates an element node of a particular type type, and the props parameter can contain an attr object or a style object. DOM tree operationappendChild(node: Node)insertBefore(node: Node, before: Node?) The two interfaces are similar to HT
 ML DOM. insertAfter(node: Node, after: Node?) Insert a new node before a child node. removeChild(node: Node, preserved: boolean?) Delete the child node node. Parameters preserved whether it is immediately removed from memory or temporarily retained. clear() Clear all child nodes. The DOM property itself operatessetAttr(key: string, value: string, silent: boolean?) setStyle(key: string, value: string, silent: boolean?) In the above two interfaces, when silent is true, the node only updates itself, does not pass the command to the client render layer. This parameter is used to handle user events that have changed the node-related properties at the time of occurrence, and will not send commands repeatedly to the client after the Native DOM has changed. addEvent(type: string, handler: Function) removeEvent(type: string) fireEvent(type: string, e: any) Bind events, unbind events, trigger events. Component method for a specific component typeSpecial: Different component types can have the
 ir own unique methods, such as <web> components support refresh method. You can see the description of each component. In this case, we will generate a specific component type of class, such as WebElement, which inherited from Element. Such as: WebElement inherited from ElementIndicates that a webview is embedded in the Wex page Refresh (): Refreshes the current webview Read-only member variables or methodsref, nextSibling, previousSibling, parentNode Inherited from Node. nodeType: number The number is always 1. type: string Consistent with the type in the constructor. attr: Object The key pair of all the characteristics of the current node. It is recommended to use the setAttr () method to modify, rather than directly modify the object here. style: Object The value of all the keys of the current node. It is recommended to modify the setStyle () method, rather than directly modify the object here. event: Object All events of the current node are bound. Each event type correspo
 nds to an event handler method. It is recommended to use the addEvent () / removeEvent () method to modify, rather than directly modify the object here. toJSON(): Object Returns a JSON object that describes the element’s node, such as: {ref: string, type: string, attr: Object, style: Object, event: Array (string), children: Array}. Comment class, inherited from NodeConstructornew Comment(value: string) Read-only member variables or methodsref, nextSibling, previousSibling, parentNode Inherited from Node. nodeType: number The number is always 8. type: string The type is always 'comment' value: string Consistent with the value in the constructor. toJSON(): Object Returns a JSON object describing the annotation node. For example: <! - value ->.","type":"references"},{"title":"Weex Variable","path":"references/weex-variable.html","permalink":"https://weex.apache.org/references/weex-variable.html","text":"Weex instance variableEach Weex page has a separate weex variable, 
 which exists in the JS context. They hold a single instance or method of the current Weex page. weex.config This variable contains all the environment information for the current Weex page, including not only: BundleUrl: string: The URL of the JS bundle. Env: Object: environment object. WeexVersion: string: Weex sdk version. AppName: string: application name. AppVersion: string: app version. Platform: string: platform information, that is iOS, Android or Web. OsVersion: string: system version. DeviceModel: string: device model (native application only). DeviceWidth: number: device width, default 750. DeviceHeight: number: device height. weex.requireModule(module: string): Object Get all the methods of a native module, such as: <template> <div><text>Hello World</text></div> </template> <script> var modal = weex.requireModule('modal') modal.toast({ message: 'I am a toast.', duration: 3 }) </script> weex.document: Document Returns the doc
 ument object of the current Weex page.","type":"references"},{"title":"Web standards","path":"references/web-standards.html","permalink":"https://weex.apache.org/references/web-standards.html","text":"Web standardsHTMLrefs: https://www.advancedwebranking.com/html/ 2016-12-11 Overview percentage name supported 98.1% <head> - 97.9% <body> - 97.9% <html> - 97% <title> - 93.9% <meta> - 89.9% <div> ✓ 89.6% <a> ✓ 88.5% <script> ✓ 86.5% <link> - 86.3% <img> ✓ 81.5% <p> - (can be customized) 75.6% <span> - (can be customized) 73.8% <li> - (can be customized) 73.7% <ul> - (can be customized) 70.3% <br> ✕ 60.4% <style> ✓ 55.8% <h1> - (can be customized) 52.7% <h2> - (can be customized) 48.4% <input> ✓ 46.9% <form> ✕ 44.3% <strong> - (can be customized) 43.1% <h3> - (can be customized) 30.9% <table> ✕ 30.3% <tr> ✕ 30.2% <td> 
  Forms percentage name supported 49.5% <option> ✕ 30.2% <input> ✓ 16.6% > [type="hidden"] - 8% > [type="text"] ✓ 4.2% > [type="submit"] - 2% > [type="checkbox"] - (<switch>) 1.2% > [type="email"] ✓ 1.1% > [type="radio"] ✕ 0.9% > [type="image"] - 0.8% > [type="button"] - 0.6% > [type="search"] ✕ 0.6% > [type="password"] ✓ 0.1% > [type="tel"] ✓ 0.1% > [type="number"] ✓ 0% > [type="reset"] - 0% > [type="file"] ✕ 0% > [type="date"] ✓ 0% > [type="url"] ✓ 0% > [type="range"] ✕ 0% > [type="color"] ✕ 0% > [type="time"] ✓ 0% > [type="datetime-local"] ✕ 7.2% <label> - 6.1% <form> - 3.7% <button> - (can be customized) 2.6% > [type="button"] - 1.3% > [typ
 e="submit"] - 0% > [type="reset"] - 1.9% <select> ✕ 0.7% <textarea> ✓ 0.5% <fieldset> - 0.1% <optgroup> ✕ 0.1% <legend> - 0% <progress> ✕ 0% <datalist> - 0% <output> - 0% <meter> - CSS Propertiesrefs: https://www.chromestatus.com/metrics/feature/popularity 2016-12-11 percentage name supported 90.5115% display ✕ flex only 89.8243% margin ✓ (not support combo) 88.7012% width ✓ 88.6468% overflow ✓ iOS only, hidden only for Android 88.6432% background-color ✓ 88.0803% height ✓ 87.7648% font-size ✓ 87.3837% padding ✓ 87.2721% color ✓ 86.9788% text-align ✓ 86.6841% position ✓ relative by default, static not supported 86.6039% font-family ✓ 86.5943% font-weight ✓ 85.0072% opacity ✓ 80.6911% max-width ✕ 79.4476% box-sizing ✕ border-box only 75.7623% max-height ✕ 74.9939% webkit-user-select ✕ 57.0292% align-items ✓ 56.8182% justify-content ✓ space-around not supported 
 well in browser 50.5941% flex-direction ✓ 48.5052% border ✓ 47.5161% top ✓ 46.9136% background ✕ 46.1552% cursor ✕ 46.1443% margin-left ✓ 46.0956% left ✓ 46.0848% text-decoration ✓ 45.9575% float ✕ 45.8391% border-bottom ✓ 45.7639% padding-left ✓ 45.7128% margin-top ✓ 45.7013% line-height ✓ 45.5836% background-image ✕ 45.0837% z-index ✕ 45.0649% right ✓ 45.0516% margin-bottom ✓ 45.0459% white-space ✕ 44.8710% margin-right ✓ 44.8476% vertical-align ✕ 44.6306% padding-top ✓ 44.1466% border-radius ✓ 44.0136% border-top ✓ 43.9815% padding-bottom ✓ 43.9392% padding-right ✓ 43.8539% visibility ✕ 43.4306% background-position ✕ 43.4098% background-repeat ✕ 43.0391% clear ✕ 42.9100% bottom ✓ 42.2092% content ✕ 42.0690% box-shadow ✕ 41.9004% border-color ✓ 41.7341% outline ✕ 41.4297% border-right ✓ 41.2605% border-left ✓ 41.1127% min-height ✕ 41.0736% font-style ✓ 41.0523% min-width ✕ 40.4298% list-style ✕ 39.7341
 % font ✕ 38.8999% background-size ✕ 38.7811% border-width ✓ 38.7718% border-collapse ✕ 37.8110% border-style ✓ 37.4962% text-overflow ✓ must work with lines 37.3471% text-transform ✕ 37.2154% transition ✕ 36.5155% overflow-y ✕ 36.3025% transform ✕ 36.2488% text-indent ✕ 35.5075% text-shadow ✕ 34.7607% webkit-appearance ✕ 34.1925% list-style-type ✕ 34.0238% border-spacing ✕ 33.6664% word-wrap ✕ 31.9961% overflow-x ✕ 31.9922% zoom ✕ 31.2495% border-bottom-left-radius ✕ 31.1306% pointer-events ✕ 31.1229% border-top-left-radius ✕ 30.2131% border-bottom-color ✓ 29.9608% border-top-color ✓ 29.4297% border-bottom-right-radius ✕ 29.2668% border-top-right-radius ✕ 28.6489% letter-spacing ✕ 27.8327% animation ✕ 26.6738% border-right-width ✓ 26.0169% src ✕ 25.2661% clip ✕ 25.2512% webkit-font-smoothing ✕ 25.1971% border-bottom-width ✓ 25.0246% border-right-color ✓ 24.7790% direction ✕ 24.4094% webkit-tap-highlight-color ✕ 23
 .9751% border-left-color ✓ 23.9321% border-top-width ✓ 23.7902% fill ✕ 23.2617% border-left-width ✓ 22.7278% table-layout ✕ 21.5766% word-break ✕ 20.4319% background-clip ✕ 19.3198% transform-origin ✕ 18.9233% filter ✕ 17.7879% resize ✕ 16.2501% flex ✕ 15.1656% font-variant ✕ 14.9181% text-rendering ✕ 14.7125% webkit-filter ✕ 14.5263% transition-duration ✕ 14.3966% transition-property ✕ 14.2124% webkit-box-orient ✕ 13.5432% outline-offset ✕ 12.9300% transition-timing-function ✕ 12.2788% unicode-range ✕ 12.0880% word-spacing ✕ 11.9124% quotes ✕ 11.6800% border-bottom-style ✓ 11.4263% webkit-background-clip ✕ 11.0070% flex-grow ✕ 10.5925% backface-visibility ✕ 10.4417% animation-name ✕ 10.4302% stroke ✕ 10.4144% animation-duration ✕ 10.2804% touch-action ✕ 9.9663% list-style-position ✕ 9.8662% order ✕ 9.7770% outline-width ✕ 9.7504% transition-delay ✕ 9.4689% border-top-style ✓ 9.3474% webkit-box-pack ✕ 9.3078% we
 bkit-box-align ✕ 9.2375% page-break-inside ✕ 9.1898% webkit-line-clamp ✕ 8.9350% list-style-image ✕ 8.8339% page-break-after ✕ 8.5735% speak ✕ 8.4754% unicode-bidi ✕ 8.4307% animation-timing-function ✕ 8.1464% webkit-box-flex ✕ 8.0048% orphans ✕ 7.9947% widows ✕ 7.6671% flex-wrap ✓ not supported well in browser 7.5756% animation-fill-mode ✕ 7.4163% animation-delay ✕ 7.3284% border-left-style ✓ 7.1586% outline-color ✕ 6.9102% flex-shrink ✕ 6.7754% perspective ✕ 6.7748% border-right-style ✓ 6.4619% outline-style ✕ 6.0382% animation-iteration-count ✕ 5.9838% background-origin ✕ 5.9714% fill-opacity ✕ 5.9357% will-change ✕ 5.3740% stroke-width ✕ 5.3172% transform-style ✕ 5.2608% overflow-wrap ✕ 5.1730% background-attachment ✕ 4.9039% counter-increment ✕ 4.5950% counter-reset ✕ 4.5031% align-self ✕ 4.4109% webkit-box-ordinal-group ✕ 4.4046% webkit-animation-direction ✕ 3.7598% background-position-x ✕ 3.6867% border-image
  ✕ 3.6601% background-position-y ✕ 3.5749% webkit-user-drag ✕ 3.3376% flex-basis ✕ 3.1840% align-content ✕ 3.1832% flex-flow ✕ 3.1774% image-rendering ✕ 3.0879% webkit-margin-start ✕ 2.9551% font-stretch ✕ 2.8934% empty-cells ✕ 2.7619% webkit-margin-after ✕ 2.7220% perspective-origin ✕ 2.6125% webkit-margin-end ✕ 2.6089% column-count ✕ 2.5880% webkit-text-fill-color ✕ 2.5466% webkit-box-direction ✕ 2.4618% font-feature-settings ✕ 2.3959% webkit-mask-image ✕ 2.3431% webkit-padding-end ✕ 2.2555% stroke-dasharray ✕ 2.1788% user-select ✕ 2.1679% object-fit ✕ 2.0643% column-gap ✕ 2.0459% text-size-adjust ✕ 2.0253% caption-side ✕ 1.9695% stroke-dashoffset ✕ 1.7923% stroke-linecap ✕ 1.7861% animation-direction ✕ 1.7559% webkit-font-feature-settings ✕ 1.7404% stroke-opacity ✕ 1.5926% stroke-miterlimit ✕ 1.5786% fill-rule ✕ 1.4859% webkit-user-modify ✕ 1.3439% webkit-border-image ✕ 1.3091% animation-play-state ✕ 1.2676% co
 ntain ✕ 1.2029% webkit-padding-start ✕ 1.1840% webkit-margin-before ✕ 1.1269% page-break-before ✕ 1.1222% webkit-margin-top-collapse ✕ 1.0418% columns ✕ 1.0354% webkit-mask-size ✕ 0.9650% border-image-slice ✕ 0.9425% stop-color ✕ 0.9408% webkit-mask-repeat ✕ 0.9125% webkit-box-lines ✕ 0.8804% webkit-column-break-inside ✕ 0.8752% size ✕ 0.8334% font-kerning ✕ 0.8034% stroke-linejoin ✕ 0.7869% tab-size ✕ 0.7689% break-inside ✕ 0.7589% webkit-text-stroke-width ✕ 0.7353% column-width ✕ 0.6924% webkit-mask-position ✕ 0.6869% border-image-width ✕ 0.6323% border-image-repeat ✕ 0.5994% border-image-outset ✕ 0.5885% all ✕ 0.5859% webkit-text-stroke-color ✕ 0.5435% webkit-print-color-adjust ✕ 0.5420% webkit-text-stroke ✕ 0.5195% writing-mode ✕ 0.4741% clip-rule ✕ 0.4685% webkit-clip-path ✕ 0.4578% text-anchor ✕ 0.4535% shape-rendering ✕ 0.4526% webkit-column-break-before ✕ 0.4494% clip-path ✕ 0.4452% webkit-mask ✕ 0.4393% m
 ix-blend-mode ✕ 0.4166% text-align-last ✕ 0.4033% column-rule ✕ 0.3990% webkit-mask-box-image ✕ 0.3989% font-variant-ligatures ✕ 0.3881% column-fill ✕ 0.3865% webkit-line-break ✕ 0.3857% border-image-source ✕ 0.3528% stop-opacity ✕ 0.3075% webkit-perspective-origin-y ✕ 0.3054% webkit-perspective-origin-x ✕ 0.2994% webkit-writing-mode ✕ 0.2717% dominant-baseline ✕ 0.2634% column-rule-color ✕ 0.2586% webkit-box-decoration-break ✕ 0.2467% webkit-text-security ✕ 0.2374% webkit-background-origin ✕ 0.2146% font-variant-caps ✕ 0.2005% column-rule-style ✕ 0.1976% shape-outside ✕ 0.1971% webkit-padding-before ✕ 0.1896% break-after ✕ 0.1782% webkit-padding-after ✕ 0.1774% text-orientation ✕ 0.1747% webkit-text-orientation ✕ 0.1655% mask ✕ 0.1626% alignment-baseline ✕ 0.1572% page ✕ 0.1530% webkit-column-break-after ✕ 0.1521% webkit-box-reflect ✕ 0.1504% webkit-text-emphasis-color ✕ 0.1499% object-position ✕ 0.1470% break-before 
  0.1455% webkit-margin-collapse ✕ 0.1452% baseline-shift ✕ 0.1451% hyphens ✕ 0.1309% rx ✕ 0.1304% ry ✕ 0.1256% background-blend-mode ✕ 0.1136% font-variant-numeric ✕ 0.1135% background-repeat-x ✕ 0.1123% background-repeat-y ✕ 0.1086% webkit-text-emphasis ✕ 0.1058% webkit-rtl-ordering ✕ 0.1040% column-rule-width ✕ 0.1036% isolation ✕ 0.1002% webkit-highlight ✕ 0.0843% webkit-transform-origin-y ✕ 0.0786% webkit-transform-origin-x ✕ 0.0770% webkit-app-region ✕ 0.0685% column-span ✕ 0.0653% r ✕ 0.0611% y ✕ 0.0602% x ✕ 0.0555% webkit-border-vertical-spacing ✕ 0.0545% webkit-border-horizontal-spacing ✕ 0.0542% webkit-border-start-width ✕ 0.0450% webkit-border-start-color ✕ 0.0424% webkit-border-after-width ✕ 0.0424% webkit-border-before-width ✕ 0.0423% webkit-border-end-width ✕ 0.0351% marker ✕ 0.0349% webkit-border-end-color ✕ 0.0347% webkit-border-after-color ✕ 0.0347% webkit-border-before-color ✕ 0.0342% mask-type ✕ 0.
 0328% color-interpolation-filters ✕ 0.0325% webkit-border-end ✕ 0.0319% vector-effect ✕ 0.0307% color-rendering ✕ CSS Units and Valuesrefs: https://drafts.csswg.org/css-values/ 2016-12-11 Textual pre-defined keywords CSS-wide keywords initial inherit unset <custom-ident>: author-defined identifiers ✓ <string>: quoted strings ("xxx") <url>: resourec locators (url()) Numeric <integer> ✓ <number> ✓ <percentage> Length <length> relative font-relative em ex ch ic rem ✓🔧 viewport-percentage vw ✓🔧 vh ✓🔧 vi vb vmin ✓🔧 vmax ✓🔧 absolute cm ✓🔧 mm ✓🔧 Q ✓🔧 in ✓🔧 pc ✓🔧 pt ✓🔧 px autofixed to number Quantities <angle> deg grad rad turn <time> s ms <frequency> Hz kHz <resolution> dpi dpcm dppx Elsewhere <color> ✓ <image> <position> Functional calc() toggle() attr() JS APIsrefs: https://www.w3.org/standards/techs/js 2016-12-11 Completed W
 orkStandards last update spec supported 2016-11-17 Media Source Extensions™ - (media related) 2016-11-08 Geolocation API Specification 2nd Edition ✕ developing 2016-10-27 Pointer Lock - 2016-10-18 Vibration API (Second Edition) ✕ 2016-04-19 Web Storage (Second Edition) ✓ async storage module 2015-10-22 Web Notifications ✕ 2015-05-19 HTML5 Web Messaging ✕ BroadcastChannel developing 2015-02-24 Pointer Events - 2015-02-10 Vibration API ✕ 2015-02-03 Server-Sent Events ✕ 2015-01-08 Indexed Database API ✕ 2014-03-13 Metadata API for Media Resources 1.0 - (media related) 2014-02-11 Progress Events ✕ 2014-01-16 JSON-LD 1.0 Processing Algorithms and API - 2013-12-12 Performance Timeline - (perf related) 2013-12-12 User Timing - (perf related) 2013-10-31 Widget Interface - 2013-10-29 Page Visibility (Second Edition) ✕ onviewappear/onviewdisappear 2013-10-10 Touch Events ✕ 2013-02-21 Selectors API Level 1 - 2012-12-17 Navigation Timing - (perf related) 2012-12-17 High 
 Resolution Time - (perf related) 2008-12-22 Element Traversal Specification - DraftsProposed Recommendations last update spec supported 2016-09-15 WebIDL Level 1 - Candidate Recommendations last update spec supported 2016-12-08 Performance Timeline Level 2 - (perf related) 2016-11-22 Page Visibility Level 2 ✕ onviewappear/onviewdisappear 2016-11-01 High Resolution Time Level 2 - (perf related) 2016-08-18 DeviceOrientation Event Specification ✕ 2016-07-21 Resource Timing Level 1 - (perf related) 2016-07-14 Presentation API - 2016-07-07 Battery Status API ✕ 2016-07-05 Encrypted Media Extensions - 2016-05-19 Media Capture and Streams - (media related) 2014-12-11 Web Cryptography API - 2014-09-09 HTML Media Capture - (media related) 2012-09-20 The WebSocket API ✕ Last Call Drafts last update spec supported 2011-12-01 Geolocation API Specification Level 2 ✕ Other Working Drafts last update spec supported 2016-12-09 MediaStream Image Capture - (media related) 2016-12-06 MediaStr
 eam Recording - (media related) 2016-12-06 Selection API ✕ 2016-12-05 Input Events ✕ 2016-12-02 Gamepad - 2016-11-29 WebDriver - 2016-11-24 WebRTC 1.0: Real-time Communication Between Browsers ✕ 2016-11-22 Pointer Lock 2.0 - 2016-11-07 Remote Playback API - (media related) 2016-11-03 Resource Timing Level 2 - (perf related) 2016-11-02 Audio Output Devices API - (media related) 2016-11-01 Indexed Database API 2.0 ✕ 2016-11-01 User Timing Level 2 - (perf related) 2016-10-31 The Screen Orientation API ✕ 2016-10-31 High Resolution Time Level 3 - (perf related) 2016-10-24 UI Events KeyboardEvent code Values - 2016-10-24 UI Events KeyboardEvent key Values - 2016-10-11 Service Workers 1 ✕ 2016-09-21 Identifiers for WebRTC’s Statistics API - 2016-09-13 Accelerometer Sensor ✕ 2016-09-13 Gyroscope Sensor ✕ 2016-09-13 Magnetometer Sensor ✕ 2016-08-30 Ambient Light Sensor ✕ 2016-08-30 Media Capture from DOM Elements - (media related) 2016-08-30 Generic Sensor API ✕ 2016-
 08-03 Wake Lock API ✕ 2016-07-19 Proximity Sensor ✕ 2016-07-19 Pointer Events - Level 2 - 2016-07-14 Screen Capture ✕ 2016-07-12 Media Capture Depth Stream Extensions - (media related) 2016-05-17 Cooperative Scheduling of Background Tasks ✕ 2016-04-22 Navigation Timing Level 2 - (perf related) 2016-04-03 Clipboard API and events ✕ clipboard module 2015-12-15 Push API ✕ 2015-12-08 Web Audio API - (media related) 2015-10-15 FindText API - 2015-09-24 Web Workers ✕ 2015-04-21 File API ✕ 2014-02-20 Network Service Discovery ✕ 2012-03-06 MediaStream Capture Scenarios - (media related) 2011-12-15 Audio Processing API - (media related)","type":"references"},{"title":"构建全新应用","path":"cn/guide/dev-with-weexpack.html","permalink":"https://weex.apache.org/cn/guide/dev-with-weexpack.html","text":"构建全新应用Work in process.","type":"guide"},{"title":"集成 Weex 到已有应用","path":"cn/guide/integrate-to-your-app.html","permalink":"https://weex.apache.org
 /cn/guide/integrate-to-your-app.html","text":"集成 Weex 到已有应用集成到 Android注:以下文档都是假设您已经具备一定的Android开发经验。 Android 集成有两种方式 源码依赖:能够快速使用WEEX最新功能,可以根据自己项目的特性进行相关改进。 SDK依赖:WEEX 会在jcenter 定期发布稳定版本。jcenter注:国内可能需要翻墙 前期准备 已经安装了JDK version>=1.7 并配置了环境变量 已经安装Android SDK 并配置环境变量。 Android SDK version 23 (compileSdkVersion in build.gradle) SDK build tools version 23.0.1 (buildToolsVersion in build.gradle) Android Support Repository >= 17 (for Android Support Library) 快速接入如果你是尝鲜或者对稳定性要求比较高可以使用依赖SDK的方式。步骤如下: 创建Android工程,没有什么要特别说明的,按照你的习惯来。 修改build.gradle 加入如下基础依赖 compile 'com.android.support:recyclerview-v7:23.1
 .1'compile 'com.android.support:support-v4:23.1.1'compile 'com.android.support:appcompat-v7:23.1.1'compile 'com.alibaba:fastjson:1.1.46.android'compile 'com.taobao.android:weex_sdk:0.5.1@aar' 注:版本可以高不可以低。 代码实现注:附录中有完整代码地址 实现图片下载接口,初始化时设置。 package com.weex.sample;import android.widget.ImageView;import com.taobao.weex.adapter.IWXImgLoaderAdapter;import com.taobao.weex.common.WXImageStrategy;import com.taobao.weex.dom.WXImageQuality;/** * Created by lixinke on 16/6/1. */public class ImageAdapter implements IWXImgLoaderAdapter { @Override public void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy) { //实现你自己的图片下载,否则图片无法显示。 }} 初始化 package com.weex.sample;import android.app.Application;import com.taobao.weex.InitConfig;import com.taobao.weex.WXSDKEngine;/** * 注意要在Manifest中设置android:name=\".
 WXApplication\" * 要实现ImageAdapter 否则图片不能下载 * gradle 中一定要添加一些依赖,否则初始化会失败。 * compile 'com.android.support:recyclerview-v7:23.1.1' * compile 'com.android.support:support-v4:23.1.1' * compile 'com.android.support:appcompat-v7:23.1.1' * compile 'com.alibaba:fastjson:1.1.45' */public class WXApplication extends Application { @Override public void onCreate() { super.onCreate(); InitConfig config=new InitConfig.Builder().setImgAdapter(new ImageAdapter()).build(); WXSDKEngine.initialize(this,config); }} 开始渲染 package com.weex.sample;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import com.taobao.weex.IWXRenderListener;import com.taobao.weex.WXSDKInstance;import com.taobao.weex.common.WXRenderStrategy;import com.taobao.weex.utils.WXFileUtils;public class MainActivity extends AppCompatActivity implements IWXRenderListener { WXSDKInstance mWXSDKInstan
 ce; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWXSDKInstance = new WXSDKInstance(this); mWXSDKInstance.registerRenderListener(this); /** * WXSample 可以替换成自定义的字符串,针对埋点有效。 * template 是.we transform 后的 js文件。 * option 可以为空,或者通过option传入 js需要的参数。例如bundle js的地址等。 * jsonInitData 可以为空。 * width 为-1 默认全屏,可以自己定制。 * height =-1 默认全屏,可以自己定制。 */ mWXSDKInstance.render(\"WXSample\", WXFileUtils.loadFileContent(\"hello.js\", this), null, null, -1, -1, WXRenderStrategy.APPEND_ASYNC); } @Override public void onViewCreated(WXSDKInstance instance, View view) { setContentView(view); } @Override public void onRenderSuccess(WXSDKInstance instance, int width, int height) { } @Override public void onRefreshSuccess(WXSDKInstance i
 nstance, int width, int height) { } @Override public void onException(WXSDKInstance instance, String errCode, String msg) { } @Override protected void onResume() { super.onResume(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityResume(); } } @Override protected void onPause() { super.onPause(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityPause(); } } @Override protected void onStop() { super.onStop(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityStop(); } } @Override protected void onDestroy() { super.onDestroy(); if(mWXSDKInstance!=null){ mWXSDKInstance.onActivityDestroy(); } }} 源码依赖(IDE Android Studio) 下载源码 git clone https://github.com/alibaba/weex 创建 Android 工程。 通过以下路径引入 SDK ModuleFile->New-Import Module-> 选择 WEEX SDK Module(weex/android/sdk) -> Finish app 的 build.gradle 中添加如下依赖:compile pr
 oject(':weex_sdk') 其他设置请参考上面快速接入 附录WXSample地址 https://github.com/xkli/WXSample.git 集成到 iOS通过cocoaPods 集成 Weex iOS SDK到你的项目首先假设你已经完成了安装 iOS 开发环境 和 CocoaPods 第一步:添加依赖导入 Weex iOS SDK 到你已有的项目, 如果没有,可以参考新建项目在继续下面内容之前,确保你已有的项目目录有名称为 Podfile 文件,如果没有,创建一个,用文本编辑器打开 集成 framework WeexSDK 在 cocoaPods 上最新版本 可以在这获取 在 Podfile 文件中添加如下内容 source 'git@github.com:CocoaPods/Specs.git' target 'YourTarget' do platform :ios, '7.0' pod 'WeexSDK', '0.9.5' ## 建议使用WeexSDK新版本 end 源码集成 首先 拷贝 ios/sdk 目录到你已有项目目录 (此处以拷贝到你已有项目的根目录为例子),然后在 Podfile 文件中添加 source 'git@git
 hub.com:CocoaPods/Specs.git' target 'YourTarget' do platform :ios, '7.0' pod 'WeexSDK', :path=>'./sdk/' end 第二步:安装依赖打开命令行,切换到你已有项目 Podfile 这个文件存在的目录,执行 pod install,没有出现任何错误表示已经完成环境配置。 第三步:初始化 Weex 环境在 AppDelegate.m 文件中做初始化操作,一般会在 didFinishLaunchingWithOptions 方法中如下添加。 //business configuration[WXAppConfiguration setAppGroup:@"AliApp"];[WXAppConfiguration setAppName:@"WeexDemo"];[WXAppConfiguration setAppVersion:@"1.0.0"];//init sdk enviroment [WXSDKEngine initSDKEnviroment];//register custom module and component,optional[WXSDKEngine registerComponent:@"MyView" withClass:[MyViewComponent class]];[WXSDKEngine registerModule:@"event" withClass:[WXEventModule class]];//register the implementation of protocol, optional[WX
 SDKEngine registerHandler:[WXNavigationDefaultImpl new] withProtocol:@protocol(WXNavigationProtocol)];//set the log level [WXLog setLogLevel: WXLogLevelAll]; 第四步:渲染 weex InstanceWeex 支持整体页面渲染和部分渲染两种模式,你需要做的事情是用指定的 URL 渲染 Weex 的 view,然后添加到它的父容器上,父容器一般都是 viewController。 #import <WeexSDK/WXSDKInstance.h>- (void)viewDidLoad { [super viewDidLoad]; _instance = [[WXSDKInstance alloc] init]; _instance.viewController = self; _instance.frame = self.view.frame; __weak typeof(self) weakSelf = self; _instance.onCreate = ^(UIView *view) { [weakSelf.weexView removeFromSuperview]; [weakSelf.view addSubview:weakSelf.weexView]; }; _instance.onFailed = ^(NSError *error) { //process failure }; _instance.renderFinish = ^ (UIView *view) { //process renderFinish }; [_instance renderWithURL:self.url options:@{@"bundleUrl":[self.url a
 bsoluteString]} data:nil];} WXSDKInstance 是很重要的一个类,提供了基础的方法和一些回调,如 renderWithURL, onCreate, onFailed 等,可以参见 WXSDKInstance.h 的声明。 第五步:销毁 Weex Instance 在 viewController 的 dealloc 阶段 销毁掉 Weex instance,释放内存,避免造成内存泄露。 - (void)dealloc{ [_instance destroyInstance];} 导入 Weex SDK framework 到工程 可以通过源码编译出 Weex SDK,可以在新的 feature 或者 bugfix 分支,尝试最新的 feature。 参考此处直接导入 weexSDK。","type":"guide"},{"title":"Android APIs","path":"cn/references/android-apis.html","permalink":"https://weex.apache.org/cn/references/android-apis.html","text":"Android APIsWeex 初步接入请参考:https://github.com/weexteam/article/issues/25 WXSDKEngine 是 Weex 对外的总入口。主要提供了一下功能: 设置相关 Adapter 和获取 adapter。 注册自定义 module 和 component 重置 JS
 Framework Adapter 介绍Weex 为了重用 Native 通用库提供了对应的接口进行设置。 IWXImgLoaderAdapter 图片适配器。 Weex 会把需要设置图片的 View 和 URL 透露出来,Native 端需要实现这个接口进行图片下载。 Weex 没有提供图片默认实现。 接口定义如下: public interface IWXImgLoaderAdapter { void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);} WXImageQuality 表示图片的质量,WXImageQuality 取如下值 LOW, NORMAL, HIGH, ORIGINAL 图片质量依次变高。默认为 LOW。WXImageStrategy 为扩展类,表示了图片是否可以裁剪 (isClipping) 锐化 (isSharpen) 占位符 (placeHolder) 等。 IWXHttpAdapter 网络下载适配器。 Weex 自定义了 WXRequest 和 OnHttpListener,Native 重载接口后可以从 Request 中获取URL,Header 等参数,网络请求完成后可以通过 OnHttpListener 进行回调通知。Weex 提供了默认网络请求:Defau
 ltWXHttpAdapter, 使用的是 HttpURLConnection 进行网络请求。 接口定义如下: public interface IWXHttpAdapter { void sendRequest(WXRequest request, OnHttpListener listener);} WXRequest 定义了网络请求相关的参数,请求方法,请求主体,超时时间。Weex默认超时时间是3000. OnHttpListener 定义了网络请求结束后对应方法。定义如下: interface OnHttpListener { /** * start request */ void onHttpStart(); /** * headers received */ void onHeadersReceived(int statusCode,Map<String,List<String>> headers); /** * post progress * @param uploadProgress */ void onHttpUploadProgress(int uploadProgress); /** * response loaded length (bytes), full length should read from headers (content-length) * @param loadedLength */ void onHttpResponseProgress(int loadedLength); /** * http response finish * @param response */ void onHttpFinish(WXResponse response);} IWXUserTrackAdapter Weex 相关性能数据 (首屏加载
 时间、JS-Native 通信时间、dom 更新时间等) 和其他通用信息 (JSLib 文件大小, Weex SDK 版本号等)。 接口定义: public interface IWXUserTrackAdapter { void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);} Native 实现接口后可以通过 WXPerformance 和 params 获取对应的信息。WXPerformane 对应字段表示含义请参考文档:https://github.com/weexteam/article/issues/124 后续随着开发 Weex 还会定义更多的 Adapter,此文档也会定时更新。 Native 和 JS 通信 自定义事件通知 多用于某个自定义控件进行事件通知,例如自定义点击事件,响应下拉事件等。 WXSDKInstance.java public void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges){ }public void fireEvent(String elementRef,final String type, final Map<String, Object> data
 ){ fireEvent(elementRef,type,data,null);}public void fireEvent(String elementRef, String type){ fireEvent(ref,type,new HashMap<String, Object>());} elementRef:事件发生的控件 ID。 type: 自定义事件,Weex 默认以 onXxxxx 开头为自定义事件。onPullDown (下拉事件)。 data: 需要透出的参数,例如当前控件的大小,坐标等其他信息。 domChanges:更新 ref 对应控件的 Attribute 和 Style。 事件回调 多用于 Module 回调,例如定位 Module 完成后需要通知 JS。使用方法如下: public class WXLocation extends WXModule { @JSMethod public void getLocation(JSCallback callback){ //获取定位代码..... Map<String,String> data=new HashMap<>(); data.put(\"x\",\"x\"); data.put(\"y\",\"y\"); //通知一次 callback.invoke(data); //持续通知 callback.invokeAndKeepAlive(data); //invoke方法和invokeAndKeepAlive两个方法二选一 }} 注册滑动事件Weex 获取
 动事件可以通过 WXSDKInstance 注册 registerOnWXScrollListener 监听 接口定义如下: public interface OnWXScrollListener { /** * The view is not currently scrolling. */ int IDLE = RecyclerView.SCROLL_STATE_IDLE; /** * The view is currently being dragged by outside input such as user touch input. */ int DRAGGING = RecyclerView.SCROLL_STATE_DRAGGING; /** * The view is currently animating to a final position while not under * outside control. */ int SETTLING = RecyclerView.SCROLL_STATE_SETTLING; /** * Callback method to be invoked when the view has been scrolled. This will be * called after the scroll has completed. * <p> * This callback will also be called if visible item range changes after a layout * calculation. In that case, dx and dy will be 0. * */ void onScrolled(View view, int x, int y); /** * Callback method to be invoked when view's scroll state changes. * */ void onScrollStateChanged(View view, int x, int y, int newState);} 自定义NavBarWeex
  提供了 WXNavigatorModule 进行导航控制,对应的方法可以通过设置 IActivityNavBarSetter 接口进行定制。 使用方法: WXSDKEngine.setActivityNavBarSetter(new IActivityNavBarSetter(){}); 其他介绍动态适配容器因为 Android 手机的碎片化导致屏幕适配很困难。Weex 对外提供的接口 render 需要动态传入容器的宽高,但是传入的宽高有时会发生变化,例如 ActionBar 隐藏等,这是传入的 Weex 容器也要进行对应的变化。为了适应这种变化,Weex 提供了接口 WXSDKInstance.setSize(int width, int height) 来改变容器的大小。 /** * * @param width 容器宽度 * @param height 容器高度 */ public void setSize(int width, int height){}; 降级使用Weex 处于发展阶段会增加一些新的特性和功能,但是这些新的特性和功能都必须升级 SDK 才能实现,对于没有升级的应用应该怎么处理呢?可以使用降级功能。 所谓降级功能
 是 Weex 无法运行的版本或者手机,可以用 Weex h5 来代替。 Native 端可以通过接口 IWXRenderListener 中的 onException 方法进行处理,如果是主动降级 errCode 是以“|”分割的字符。“|”前面的字符为1表示主动降级,Native 端可以跳转到对应的 H5 页面。或者用其他的方式提示用户当前环境不支持 Weex。","type":"references"},{"title":"通用事件","path":"cn/references/common-event.html","permalink":"https://weex.apache.org/cn/references/common-event.html","text":"通用事件Weex 提供了通过事件触发动作的能力,例如在用户点击组件时执行 JavaScript。下面列出了可被添加到 Weex 组件上以定义事件动作的属性: click当组件上发生点击手势时被触发。 注意: <input> 和 <switch> 组件目前不支持 click 事件,请使用 change 或 input 事件来代替。 事件对象 type: click target: 触发点击事件的目标组件 timestamp: 
 触发点击事件时的时间戳 longpress如果一个组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。 注意: <input> 和 <switch> 组件目前不支持 click 事件,请使用 change 或 input 事件来代替。 事件对象 type : longpress target : 触发长按事件的目标组件 timestamp : 长按事件触发时的时间戳 Appear 事件如果一个位于某个可滚动区域内的组件被绑定了 appear 事件,那么当这个组件的状态变为在屏幕上可见时,该事件将被触发。 事件对象 type : appear target : 触发 Appear 事件的组件对象 timestamp : 事件被触发时的时间戳 direction : 触发事件时屏幕的滚动方向,up 或 down Disappear 事件如果一个位于某个可滚动区域内的组件被绑定了 disappear 事件,那么当这个组件被滑出屏幕变为不可见状态时,该事件将被触发。 事件对象 type : disappear target : 触发 Dis
 appear 事件的组件对象 timestamp : 事件被触发时的时间戳 direction : 触发事件时屏幕的滚动方向,up 或 down Page 事件注意:仅支持 iOS 和 Android,H5 暂不支持。 Weex 通过 viewappear 和 viewdisappear 事件提供了简单的页面状态管理能力。 viewappear 事件会在页面就要显示或配置的任何页面动画被执行前触发,例如,当调用 navigator 模块的 push 方法时,该事件将会在打开新页面时被触发。viewdisappear 事件会在页面就要关闭时被触发。 与组件的 appear 和 disappear 事件不同的是,viewappear 和 viewdisappear 事件关注的是整个页面的状态,所以它们必须绑定到页面的根元素上。 特殊情况下,这两个事件也能被绑定到非根元素的body组件上,例如wxc-navpage组件。 事件对象 type : viewappear 或 viewdisappear target : 触发事件的组件对象 timestamp : 事件被触发时的时间戳 示例<template> <div
 > <div class=\"box\" @click=\"onclick\" @longpress=\"onlongpress\" @appear=\"onappear\" @disappear=\"ondisappear\"></div> </div></template><script> const modal = weex.requireModule('modal') export default { methods: { onclick (event) { console.log('onclick:', event) modal.toast({ message: 'onclick', duration: 0.8 }) }, onlongpress (event) { console.log('onlongpress:', event) modal.toast({ message: 'onlongpress', duration: 0.8 }) }, onappear (event) { console.log('onappear:', event) modal.toast({ message: 'onappear', duration: 0.8 }) }, ondisappear (event) { console.log('ondisappear:', event) modal.toast({ message: 'ondisappear', duration: 0.8 }) } } }</script><style scoped> .box { border-width: 2px; border-style: solid; border-color: #BBB; width: 250px; height: 250px; margin-top: 250px; margin-left: 250px; background-color: #EEE; &#125
 ;</style>","type":"references"},{"title":"颜色名称列表","path":"cn/references/color-names.html","permalink":"https://weex.apache.org/cn/references/color-names.html","text":"Weex 支持的所有颜色名称基础颜色关键词: 颜色名 十六进制RGB值 black(黑) #000000 silver(银) #C0C0C0 gray(灰) #808080 white(白) #FFFFFF maroon(褐紫红) #800000 red(红) #FF0000 purple(紫) #800080 fuchsia(晚樱) #FF00FF green(绿) #008000 lime(石灰) #00FF00 olive(橄榄) #808000 yellow(黄) #FFFF00 navy(海军蓝) #000080 blue(蓝) #0000FF teal(水鸭) #008080 aqua(水蓝) #00FFFF 扩展颜色关键词: 颜色名 十六进制RGB值 aliceblue #F0F8FF antiquewhite #FAEBD7 aqua #00FFFF aquamarine #7FFFD4 azure #F0FFFF beige #F5F5DC bisque #FFE4C4 black #000000 blanchedalmond #FFEBCD blue #0000FF blueviolet #8A2BE2 brown #A52A2A burlywood #DEB887 cadetblue #5F9EA0 chartreuse #7FFF00 chocolate #D2691E coral #FF7F50 cornflowerblue #6495ED cornsilk #FFF8DC crimson #DC143C cyan #0
 0FFFF darkblue #00008B darkcyan #008B8B darkgoldenrod #B8860B darkgray #A9A9A9 darkgreen #006400 darkgrey #A9A9A9 darkkhaki #BDB76B darkmagenta #8B008B darkolivegreen #556B2F darkorange #FF8C00 darkorchid #9932CC darkred #8B0000 darksalmon #E9967A darkseagreen #8FBC8F darkslateblue #483D8B darkslategray #2F4F4F darkslategrey #2F4F4F darkturquoise #00CED1 darkviolet #9400D3 deeppink #FF1493 deepskyblue #00BFFF dimgray #696969 dimgrey #696969 dodgerblue #1E90FF firebrick #B22222 floralwhite #FFFAF0 forestgreen #228B22 fuchsia #FF00FF gainsboro #DCDCDC ghostwhite #F8F8FF gold #FFD700 goldenrod #DAA520 gray #808080 green #008000 greenyellow #ADFF2F grey #808080 honeydew #F0FFF0 hotpink #FF69B4 indianred #CD5C5C indigo #4B0082 ivory #FFFFF0 khaki #F0E68C lavender #E6E6FA lavenderblush #FFF0F5 lawngreen #7CFC00 lemonchiffon #FFFACD lightblue #ADD8E6 lightcoral #F08080 lightcyan #E0FFFF lightgoldenrodyellow #FAFAD2 lightgray #D3D3D3 lightgreen #90EE90 lightgrey #D3D3D3 lightpink #FFB6C1 li
 ghtsalmon #FFA07A lightseagreen #20B2AA lightskyblue #87CEFA lightslategray #778899 lightslategrey #778899 lightsteelblue #B0C4DE lightyellow #FFFFE0 lime #00FF00 limegreen #32CD32 linen #FAF0E6 magenta #FF00FF maroon #800000 mediumaquamarine #66CDAA mediumblue #0000CD mediumorchid #BA55D3 mediumpurple #9370DB mediumseagreen #3CB371 mediumslateblue #7B68EE mediumspringgreen #00FA9A mediumturquoise #48D1CC mediumvioletred #C71585 midnightblue #191970 mintcream #F5FFFA mistyrose #FFE4E1 moccasin #FFE4B5 navajowhite #FFDEAD navy #000080 oldlace #FDF5E6 olive #808000 olivedrab #6B8E23 orange #FFA500 orangered #FF4500 orchid #DA70D6 palegoldenrod #EEE8AA palegreen #98FB98 paleturquoise #AFEEEE palevioletred #DB7093 papayawhip #FFEFD5 peachpuff #FFDAB9 peru #CD853F pink #FFC0CB plum #DDA0DD powderblue #B0E0E6 purple #800080 red #FF0000 rosybrown #BC8F8F royalblue #4169E1 saddlebrown #8B4513 salmon #FA8072 sandybrown #F4A460 seagreen #2E8B57 seashell #FFF5EE sienna #A0522D silver #C0C0C0 s
 kyblue #87CEEB slateblue #6A5ACD slategray #708090 slategrey #708090 snow #FFFAFA springgreen #00FF7F steelblue #4682B4 tan #D2B48C teal #008080 thistle #D8BFD8 tomato #FF6347 turquoise #40E0D0 violet #EE82EE wheat #F5DEB3 white #FFFFFF whitesmoke #F5F5F5 yellow #FFFF00 yellowgreen #9ACD32","type":"references"},{"title":"通用样式","path":"cn/references/common-style.html","permalink":"https://weex.apache.org/cn/references/common-style.html","text":"通用样式所有 Weex 组件都支持以下通用样式规则。 盒模型 Weex 盒模型基于 CSS 盒模型,每个 Weex 元素都可视作一个盒子。我们一般在讨论设计或布局时,会提到「盒模型」这个概念。 盒模型描述了一个元素所占用的空间。每一个盒子有四条边界:外边距边界 margin edge, 边框边界 border edge, 内边距边界 padding edge 与内容边界 content edge。这四层边界,形成一层层的盒子包裹起来,这就是盒模型大体上的含义。 注
 :Weex 对于长度值目前只支持像素值,不支持相对单位(em、rem)。 width {length}:,默认值 0 height {length}:,默认值 0 padding {length}:内边距,内容和边框之间的距离。默认值 0 可有如下写法: padding-left {length}:,默认值 0 padding-right {length}:,默认值 0 padding-top {length}:,默认值 0 padding-bottom {length}:,默认值 0 margin: 外边距,元素和元素之间的空白距离。值类型为 length,默认值 0 可有如下写法: margin-left {length}:,默认值 0 margin-right {length}:,默认值 0 margin-top {length}:,默认值 0 margin-bottom {length}:,默认值 0 border: 设定边框,border 目前不支持类似这样 border: 1 solid #ff0000; 的组合写法。 可有如下写法: border-style: 设定边框样式,值类型为 string,可选值为 solid | dashed | dotted,默认值 solid 可有如下写法: border-left-style {string}:可选值为 solid | da
 shed | dotted,默认值 solid border-top-st

<TRUNCATED>


Mime
View raw message