vue中监听页面,禁止点击浏览器返回按钮返回

mounted () {
    if (window.history && window.history.pushState) {
        // 向历史记录中插入了当前页
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', this.goBack, false);
    }
},

destroyed () {
    window.removeEventListener('popstate', this.goBack, false);
},
methods: {
    goBack () {
        // console.log("点击了浏览器的返回按钮");
        history.pushState(null, null, document.URL);
    },

    不用谢 拿走用就行了

上一篇:【高危】Shiro-550反序列化漏洞复现


下一篇:Kali系统修改.bashrc文件,shell不生效之原因