禁用浏览器前进后退功能
这里使用的是Vue
// 在 main.js 中添加以下代码
// 禁用浏览器前进后退
window.history.pushState(null, null, window.location.href);
window.addEventListener('popstate', function () {
window.history.forward(-1);
window.history.pushState(null, null, window.location.href);
});
// 在每个页面加载完成时执行以下代码
window.history.pushState(null, null, window.location.href);