// 引入jq
mounted() { // 看好周期
disableBrowserBack();
history.pushState(null, null, document.URL);
if (window.history && window.history.pushState) {
$(window).on('popstate', function ()
window.history.pushState('forward', null, '');
window.history.forward(1);
});
}
//
window.history.pushState('forward', null, ''); //在IE中必须得有这两行
window.history.forward(1);
},
或者提到公共js中
util.js
import "@/xb-share/api/jquery-1.11.3.min.js";
export const disableBrowserBack = (param) => {
return (function () {
history.pushState(null, null, document.URL);
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '');
window.history.forward(1);
});
}
//
window.history.pushState('forward', null, '');
window.history.forward(1);
})()
};
页面中引用
import {disableBrowserBack} from "../../xb-share/util/util";
mounted() {
disableBrowserBack()
},
就可以了