<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js">
$scope.clickCloseWind = function () {
function ready() {
if(window.__wxjs_environment === 'miniprogram'){
wx.miniProgram.navigateTo({url: '/pages/mine/mine'})
}else{
wx.closeWindow();
}
}
if (!window.WeixinJSBridge || !WeixinJSBridge.invoke) {
document.addEventListener('WeixinJSBridgeReady', ready, false)
} else {
ready()
}
问题解决没,可能是你的原h5网站引入过旧版本的sdk,把他找出来删掉更换新的sdk应该会解决
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i) == "micromessenger") { //ios的ua中无miniProgram,但都有MicroMessenger(表示是微信浏览器) wx.miniProgram.getEnv((res)=>{ if (res.miniprogram) { console.log("小程序内跳转页面"); wx.miniProgram.navigateTo({ url: `/pages/webview/webview?url=${url}` }); } }); } else { console.log("网页端跳转页面", url); window.location.href = url; }
window.loadJs('https://res.wx.qq.com/open/js/jweixin-1.3.2.js',()=>{ let ready = ()=>{ if(window.__wxjs_environment === 'miniprogram'){ window.wx.navigateTo({url: '/pages/mine/mine'}) } } if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) { document.addEventListener('WeixinJSBridgeReady', ready, false) } else { ready() } });