前端调用app的方法,假设方法名:toCustomService
import { isIOS } from "@/util/common"
if(isIOS()) {
window.webkit.messageHandlers.toCustomService.postMessage({});
}else{
//abcd为安卓定义
window.abcd.toCustomService();
}
app调用前端的方法,前端需提前定义好
mounted() {
window.onload = () =>{
window.Callback = this.Callback
}
},
methods: {
Callback() {
console.log('哈哈')
}
}