浅谈vue router中的导航守卫

tech2022-09-13  98

导航守卫:也叫路由守卫 业务需求:动态改变页面title 1:在组件mount中 使用document.title = ‘标题名’ 2.使用前置钩子:beforeEach 它有三个参数(to,from,next) mate是元数据

const router = { path: '/apply', name: 'apply', component: apply, meta: { title: '申请' } } $riuter.debofrEach((to,from,next) =>{ document.title = to.meta.title })
最新回复(0)