You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ji...@apache.org on 2017/02/20 06:41:21 UTC
[32/50] [abbrv] incubator-weex git commit: * [ios] add doc for new
version
* [ios] add doc for new version
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/7e579b92
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/7e579b92
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/7e579b92
Branch: refs/heads/master
Commit: 7e579b92eadf816b25c8547bd1accf5673f1d220
Parents: 9b69a04
Author: acton393 <zh...@gmail.com>
Authored: Thu Feb 16 17:57:37 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Feb 16 17:57:37 2017 +0800
----------------------------------------------------------------------
.../cn/references/advanced/extend-to-android.md | 25 ++++++++++++
.../cn/references/advanced/extend-to-ios.md | 43 +++++++++++++++++++-
.../references/advanced/extend-to-android.md | 28 +++++++++++++
doc/source/references/advanced/extend-to-ios.md | 42 ++++++++++++++++++-
4 files changed, 136 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7e579b92/doc/source/cn/references/advanced/extend-to-android.md
----------------------------------------------------------------------
diff --git a/doc/source/cn/references/advanced/extend-to-android.md b/doc/source/cn/references/advanced/extend-to-android.md
index ef9c5b9..9575203 100644
--- a/doc/source/cn/references/advanced/extend-to-android.md
+++ b/doc/source/cn/references/advanced/extend-to-android.md
@@ -140,5 +140,30 @@ public class ImageAdapter implements IWXImgLoaderAdapter {
}
}
```
+#### \u7ec4\u4ef6\u65b9\u6cd5\u652f\u6301
+\u4eceWeexSDK 0.9.5\u5f00\u59cb\uff0c\u4f60\u53ef\u4ee5\u5b9a\u4e49\u7ec4\u4ef6\u65b9\u6cd5
+
+- \u5728\u7ec4\u4ef6\u4e2d\u5982\u4e0b\u58f0\u660e\u4e00\u4e2a\u7ec4\u4ef6\u65b9\u6cd5
+
+ ```java
+ @JSMethod
+ public void focus(){
+ //method implementation
+ }
+ ```
+- \u6ce8\u518c\u7ec4\u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u5728weex \u6587\u4ef6\u4e2d\u8c03\u7528
+
+ ```html
+ <template>
+ <mycomponent id='mycomponent'></mycomponent>
+ </template>
+ <script>
+ module.exports = {
+ created: function() {
+ this.$el('mycomponent').focus();
+ }
+ }
+ </script>
+ ```
\u6ce8:\u5de5\u7a0b\u8981\u6dfb\u52a0\u4f9d\u8d56 `compile 'com.squareup.picasso:picasso:2.5.2'`
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7e579b92/doc/source/cn/references/advanced/extend-to-ios.md
----------------------------------------------------------------------
diff --git a/doc/source/cn/references/advanced/extend-to-ios.md b/doc/source/cn/references/advanced/extend-to-ios.md
index 1f1d868..7fe5601 100644
--- a/doc/source/cn/references/advanced/extend-to-ios.md
+++ b/doc/source/cn/references/advanced/extend-to-ios.md
@@ -232,4 +232,45 @@ return [[WXImageView alloc] init];
```html
<image style="your-custom-style" src="image-remote-source" resize="contain/cover/stretch"></image>
-```
\ No newline at end of file
+```
+
+##### component \u65b9\u6cd5
+ WeexSDK 0.9.5 \u4e4b\u540e\u652f\u6301\u4e86\u5728js\u4e2d\u76f4\u63a5\u8c03\u7528component\u7684\u65b9\u6cd5\uff0c\u8fd9\u91cc\u63d0\u4f9b\u4e00\u4e2a\u4f8b\u5b50\uff0c
+
+ - \u81ea\u5b9a\u4e49\u4e00\u4e2aWXMyCompoenent \u7684\u7ec4\u4ef6
+
+ ```
+ @implementation WXMyComponent
+ WX_EXPORT_METHOD(@selector(focus)) // \u66b4\u9732\u8be5\u65b9\u6cd5\u7ed9js
+ - (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
+ ```
+
+ - \u6ce8\u518c\u7ec4\u4ef6 `[WXSDKEngine registerComponent:@"mycomponent" withClass:[WXMyComponent class]] `
+ - \u5728weex \u6587\u4ef6\u4e2d\u8c03\u7528
+
+ ```
+ <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/7e579b92/doc/source/references/advanced/extend-to-android.md
----------------------------------------------------------------------
diff --git a/doc/source/references/advanced/extend-to-android.md b/doc/source/references/advanced/extend-to-android.md
index ab5e08f..e382372 100644
--- a/doc/source/references/advanced/extend-to-android.md
+++ b/doc/source/references/advanced/extend-to-android.md
@@ -158,3 +158,31 @@ public class ImageAdapter implements IWXImgLoaderAdapter {
}
}
```
+
+#### Component Method
+ from WeexSDK `0.9.5`, you can define your component method
+
+ for example, define a method in component:
+
+ ```java
+
+ @JSMethod
+ public void focus(){
+ //method implementation
+ }
+
+ ```
+ after your registration for your own custom component, now you can call it in your js file.
+
+ ```html
+<template>
+ <mycomponent id='mycomponent'></mycomponent>
+</template>
+<script>
+ module.exports = {
+ created: function() {
+ this.$el('mycomponent').focus();
+ }
+ }
+</script>
+```
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7e579b92/doc/source/references/advanced/extend-to-ios.md
----------------------------------------------------------------------
diff --git a/doc/source/references/advanced/extend-to-ios.md b/doc/source/references/advanced/extend-to-ios.md
index c0d8639..133e784 100644
--- a/doc/source/references/advanced/extend-to-ios.md
+++ b/doc/source/references/advanced/extend-to-ios.md
@@ -259,4 +259,44 @@ Now you can use `<image>` and its attributes wherever you want in the template.
```html
<image style="your-custom-style" src="image-remote-source" resize="contain/cover/stretch"></image>
-```
\ No newline at end of file
+```
+
+#### Component Method
+from WeexSDK `0.9.5`, you can define your component method by macro `WX_EXPORT_METHOD`
+for example:
+
+```
+@implementation WXMyComponent
+ +WX_EXPORT_METHOD(@selector(focus))
+ +- (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
+```
+
+after your registration for your own custom component, now you can call it in your js file.
+
+```
+<template>
+ <mycomponent id='mycomponent'></mycomponent>
+</template>
+<script>
+ module.exports = {
+ created: function() {
+ this.$el('mycomponent').focus();
+ }
+ }
+</script>
+```
\ No newline at end of file