npm install vue-bridge-webview --save
把node_modules文件下的vue-bridge-webview.js手动拷贝出来放在static文件夹下
把:
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
setupWebViewJavascriptBridge(function(bridge){
$bridge = bridge
})
}else if(/(Android)/i.test(navigator.userAgent)) {
$bridge = bridge
})
}
改成:
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
setupWebViewJavascriptBridge(function(bridge){
$bridge = bridge
})
}else if(/(Android)/i.test(navigator.userAgent)) {
connectWebViewJavascriptBridge(function(bridge){
bridge.init((message, responseCallback) => {
responseCallback('get message success')
})
$bridge = bridge
})
}
就行了。
转载vue H5+原生(利用WebViewJavascriptBridge)快速开发Hybrid APP(仅前端部分)