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