File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,39 @@ vue项目中使用jsBridge技术 和原生APP通信
4
4
android [ jsBridge库] ( https://github.com/lzyzsd/JsBridge )
5
5
ios [ jsBridge库] ( https://github.com/marcuswestin/WebViewJavascriptBridge )
6
6
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
+ ```
You can’t perform that action at this time.
0 commit comments