核心提示:1.(亲测好用,并且解决了,会先返回上一级页面的bug) let url = window.location.href; pushHistory(url); window.addEventListen...
1.(亲测好用,并且解决了,会先返回上一级页面的bug)
let url = window.location.href;
pushHistory(url);
window.addEventListener('popstate', () => { WeixinJSBridge.call('closeWindow'); });
function pushHistory(url) {
var state = {
title: "myCenter",
url: url
};
window.history.pushState(state, state.title, state.url);
}
2.可以实现但有瑕疵
window.addEventListener("popstate",function(e) {
WeixinJSBridge.call('closeWindow');
},false)
3.同上
import wx from 'weixin-js-sdk'(先要引入微信的sdk-vue)
window.addEventListener("popstate",function(e) {
wx.closeWindow();
},false)
4.正常页面可以,在微信端不好用
window.history.go(-1);
window.history.back();