通過在webView中使用wx.miniProgram接口實現跳轉回小程序頁面
1.首先,先引用微信'path/to/page'路徑;
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
wx.miniProgram.navigateTo({ url: '/path/to/page' })
2.微信路徑引用后,通過wx.miniProgram.postMessage傳遞參數,使用bindmessage事件監聽實現跳轉;
wx.miniProgram.postMessage({
data: {
password: d1,
random: Random,
randJnlNo: randJnlNo
}
});
wx.miniProgram.navigateBack(); // 返回上一頁面
//wxml文件:
<web-view src="{{wxmp}}/password-control-set?token={{token}}&tfccode={{tfccode}}" bindmessage="postMessage">
//json文件:postMessage: function (e) { //webview頁面向小程序傳遞參數)
console.log(e.detail.data)
}