一 vue方法
在src目录下建立JSbridge.js文件
1. 在main.js全局引用(当然你可以在单个页面上使用)
import Bridge from './JSbridge.js' ;
Vue.prototype.$bridge = Bridge;
2. 页面使用方法(注意:onBack是方法name,ios和安卓必须统一使用这个name才能调用到方法)
let mgs = ''
this.$bridge.callHandler('onBack',mgs,(res)=>{
console.log('获取app响应数据:'+ res);
})
let isAndroid = navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1;
let isiOS = !!navigator.userAgent.mat