h5已经引入uni.webview.1.5.6.js且与APP通信
// h5端
// 向app发送消息
const judgePermission = () => {
// App 端调用
if (window.uni && uni.postMessage) {
alert('uni')
uni.webView.postMessage({
data: {
action: 'message',
},
})
}
}
App端
<view> <web-view id="web-view" ref="webview"src="aliPayUrl"
@load="onLoadtest"
@onPostMessage="handlePostMessage"
</web-view>
</view>
methods: {
onLoadtest() {
alert(1);
},
handlePostMessage(data) {
alert('收到');
console.log('接收到消息:' + JSON.stringify(data.detail));
}
}
app端里面的load和onPostMessage都不起作用
1 个回复
6***@qq.com (作者)
已解决,下个官方demo看出来的问题,然后几次安装有缓存在就现象不生效了