You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ha...@apache.org on 2018/06/21 10:01:25 UTC

incubator-weex-site git commit: Update webview.md, add postMessage method

Repository: incubator-weex-site
Updated Branches:
  refs/heads/master 86705bfd1 -> fcc117760


Update webview.md, add postMessage method

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/commit/fcc11776
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/tree/fcc11776
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/diff/fcc11776

Branch: refs/heads/master
Commit: fcc11776046d5c4e3f9dd7dd30930f2bdffb5263
Parents: 86705bf
Author: ginuim <gi...@gmail.com>
Authored: Thu Jun 21 16:31:41 2018 +0800
Committer: GitHub <no...@github.com>
Committed: Thu Jun 21 16:31:41 2018 +0800

----------------------------------------------------------------------
 source/cn/references/modules/webview.md | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/fcc11776/source/cn/references/modules/webview.md
----------------------------------------------------------------------
diff --git a/source/cn/references/modules/webview.md b/source/cn/references/modules/webview.md
index 51562df..02ab7f0 100644
--- a/source/cn/references/modules/webview.md
+++ b/source/cn/references/modules/webview.md
@@ -34,6 +34,15 @@ version: 2.1
 
 - `webElement`*(web)*: `<web>` 组件元素。
 
+### postMessage(webElement, data)
+
+向当前 Web 页面发送数据。(android weex_sdk:0.18.0-beta-3 开始支持)
+
+**参数**
+
+- `webElement`*(web)*: `<web>` 组件元素。
+- `data {Object}`: 要发送的数据
+
 ## 示例
 
 - 简单用法:
@@ -45,6 +54,12 @@ var webview = weex.requireModule('webview');
 webview.goBack(webElement.ref);
 webview.goForward(webElement.ref);
 webview.reload(webElement.ref);
+webview.postMessage(webElement, {message: 'message to Web page'});
+
+// Web 页面中接收数据
+window.addEventListener('message', event => {
+    console.log(event.data) // message to Web page
+})
 ```
 
 - [浏览器示例](http://dotwe.org/vue/a3d902040b79ab38d1ffd753366fb939)