web-view调转小程序
web-view调转小程序页面成功回调函数已经执行了,但是页面没有跳转
< head > < script type = "text/javascript" src = "https://res.wx.qq.com/open/js/jweixin-1.3.0.js" ></ script > </ head > < body > < div > < h3 >这是网页</ h3 > < button id = "btn1" >跳转到小程序的首页</ button > < button id = "btn2" >点击发送数据</ button > < p >点击第二个按钮后,然后点击小程序的回退箭头,可以获取到来自网页的数据</ p > </ div > </ body > < script > window.onload = function () { console.log(window.__wxjs_environment === 'miniprogram') var btn1 = document.getElementById('btn1'); var btn2 = document.getElementById('btn2'); btn1.onclick = function () { wx.miniProgram.redirectTo({ url: '/pages/index/index', success: function () { console.log('sucess') } }) } btn2.onclick = function () { wx.miniProgram.postMessage({ data: '来自网页的数据' }) } } </ script > </ html > |