// 这个是监听浏览器回退键的
returnButton () {
let vm = this;
if (window.history && window.history.pushState) {
window.addEventListener("popstate", function(){
window.history.pushState('forward', null, '#');
window.history.forward(1);
vm.routerBack(); //调用方法
}, false)
}
window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
window.history.forward(1);
},
在app.vue mounted的时候,监控这个回退拿,触发回退后,调用回退事件。