router.beforeEach((to,from,next)=>{
if(from.matched.length) {
window.location = to.path
} else next()
})
from 的 matched 属性,只有在 路由跳转 的时候才会存在,刷新页面是不会有的
所以不用担心 死循环刷新 的问题
router.beforeEach((to,from,next)=>{
if(from.matched.length) {
window.location = to.path
} else next()
})
from 的 matched 属性,只有在 路由跳转 的时候才会存在,刷新页面是不会有的
所以不用担心 死循环刷新 的问题