h5与app的交互

tech2026-02-26  2

之前又项目需求,要h5与app做信息交互,说白了就是互相传递方法携带参数: 做法如下 h5给app传方法

router.beforeEach((to, from, next) => { if (to.query.platform) {//固定好的系统类型的字段 store.state.platform = to.query.platform } next(); }) Vue.prototype.bridges = { jumpLink(companyAddress,longitude,latitude,companyName,companyKey) { let data = { companyAddress,longitude,latitude,companyName,companyKey:companyKey } if (store.state.platform === 'iOS') { window.webkit.messageHandlers.jumpLink.postMessage(data) return } if (store.state.platform === 'Android') { window.test.jumpLink(JSON.stringify(data)); return } }, }

h5接收app的参数

window.getAddressInfo =(data) => {.....}
最新回复(0)