引入weixin-js-sdk
npm i weixin-js-sdk
页面引入
// 引入wxjs
import wx from "weixin-js-sdk";
点击触发方法
javascript
methods: {
goweap(id){
console.log(wx);
// H5传递数据 (navigateBack)
wx.miniProgram.navigateBack({delta: 1});
wx.miniProgram.postMessage({
data: {
id: id
}
});
},
}
小程序接收信息
html
<web-view bindmessage="getMessage" src="http://localhost:8080" />
javascript
getMessage(e:any){
console.log("\(^o^)/~",e);
},