目录

小程序web-view,h5页监听返回到小程序指定页面

目录

小程序web-view,h5页监听返回到小程序指定页面

在h5页面进行监听返回跳转判断:

created(){

this.pushHistory();

window.addEventListener(“popstate”, function(e) {

//首页点击返回,直接关闭网页

WeixinJSBridge.call(‘closeWindow’);

uni.reLaunch({

url: xxxx,

});

}, false);

},

methods:{

pushHistory() {

var state = {

title: “title”,

url: “#”

};

window.history.pushState(state, state.title, state.url);

},

}

https://i-blog.csdnimg.cn/blog_migrate/45eed2aa4ba91e141b4cabe5705b1fbe.jpeg

https://i-blog.csdnimg.cn/blog_migrate/bcc1cc1a54c424fbe2f47ae4cd3995f9.jpeg

https://i-blog.csdnimg.cn/blog_migrate/a581d4fa613207aab9cb5615f5cac4ac.jpeg

小程序web-view,在h5页面监听返回到小程序指定页面进行判断,如果携带参数,在小程序onLoad里面进行接收