javascript - How to prevent browser rollback on a certain page in vue router?
给我你的怀抱
给我你的怀抱 2017-06-30 09:57:27
0
3
1399

I write a vue single-page application a>b>c. After successful login, the d page is displayed. I want to make the browser back button invalid on the d page. Please tell me how to implement it. I checked some global hooks using routing. I am currently using router hash. model

给我你的怀抱
给我你的怀抱

reply all(3)
滿天的星座

You can use router.replace(location) which will not add new records to history and replace the current history records.

洪涛

Case link

//replace
<router-link to="/D" replace>Go to D</router-link>
or
router.replace('D')
三叔

Use hooks inside components.

beforeRouteEnter (to, from, next) {
  next(vm => {
    // 通过 `vm` 访问组件实例
  })
}

You can access this directly in beforeRouteLeave. This leave hook is usually used to prevent users from leaving suddenly before saving changes. Navigation can be canceled via next(false).
From the documentation: https://router.vuejs.org/zh-c...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!