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
滿天的星座2017-06-30 09:59:27
You can use router.replace(location) which will not add new records to history and replace the current history records.
PHP中文网2017-06-30 09:59:27
Case link
//replace
<router-link to="/D" replace>Go to D</router-link>
or
router.replace('D')
三叔2017-06-30 09:59:27
Use hooks inside components.
beforeRouteEnter (to, from, next) {
next(vm => {
// 通过 `vm` 访问组件实例
})
}
You can access
this
directly inbeforeRouteLeave
. Thisleave
hook is usually used to prevent users from leaving suddenly before saving changes. Navigation can be canceled vianext(false)
.
From the documentation: https://router.vuejs.org/zh-c...