Vue disables the browser forward and backward

1. In main.js, add popstate monitoring

window.addEventListener('popstate', function() {
    history.pushState(null, null, document.URL)
})

2. Router's index.js:

const router = new Router({
 mode: 'hash',
 routes,
 scrollBehavior: () => {
  history.pushState(null, null, document.URL)
 }
})

 

Guess you like

Origin blog.csdn.net/weixin_42217154/article/details/109776249