1. Reasons for the rebound layer function of intercepting routes:

In order to improve user experience, users on mobile terminals are prone to misoperation of the back button or left slide, which leads to page rollback, especially when the large form page is not submitted. Such misoperation will waste a lot of user energy and time.

2. As required by the product, whether popover intercept can be added during the rollback

The idea is to intercept the page component lifecycle hook beforeRouteLeave and then change the Inter.

Code snippets

BeforeRouteLeave (to, from, next){if(this.interceptrouter){next(()=>{messagebox.confirm (' You may have some modifications that are not available, are you sure to return to the superior page? ').then(()=>{ this.interceptRouter = false; this.$router.go(-1) }).catch(()=>{ }) return false; })()) }else{ next() } }Copy the code

4, interceptRouter

To determine if there is any submitted data