Skip to content

Commit d4d3c97

Browse files
authored
Update README.md
1 parent cabb135 commit d4d3c97

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,39 @@ vue项目中使用jsBridge技术 和原生APP通信
44
android [jsBridge库](https://github.com/lzyzsd/JsBridge)
55
ios [jsBridge库](https://github.com/marcuswestin/WebViewJavascriptBridge)
66

7+
###在vue中使用
8+
```
9+
import {setJsBridge} from 'jsBridge-plugin' //引入插件
10+
11+
//vue生命周期钩子
12+
ready : function(){
13+
14+
//注册js方法 让原生调用
15+
setJsBridge((bridge)=>{
16+
17+
bridge.registerHandler(this.$jsBridgeCmd.publish, (data, responseCallback)=>{
18+
$("#app_resp").html("点击了提交按钮");
19+
this.publish().then((id)=>{
20+
responseCallback(id);
21+
})
22+
});
23+
24+
});
25+
}
26+
27+
methods: {
28+
//点击事件方法或者其他场景
29+
addImage(){
30+
//调用原生方法 需要原生那边也注册方法
31+
this.$jsBridge.callHandler(
32+
this.$jsBridgeCmd.chooseImage
33+
, { name : '添加图片' }
34+
, (responseData) =>{
35+
//回调函数
36+
}
37+
);
38+
},
39+
}
40+
41+
42+
```

0 commit comments

Comments
 (0)