当前位置:网站首页>route的meta配置项
route的meta配置项
2022-07-29 06:34:00 【二七二十七】
meta被称为路由元信息,是路由中携带的信息,可以通过自定义meta来实现一些路由时的功能
使用场景:比如给每一个路由对应的页面设置标题、以及判断某个页面是否需要进行权限校验
routes: [ { // 给该路由命名为guanyv name: 'guanyv', path: '/about', component: () => import('../views/About.vue') // 自定义title属性和isAuth属性,用于在路由导航守卫中使用,给页面设置标题和权限校验 meta: { title: '关于', isAuth: true} }, ... ]// 使用全局前置路由守卫对页面进行鉴权 router.beforeEach((to, form, next) => { // 通过判断是否需要进行鉴权 if (to.meta.isAuth) { if (localStroage.getItem('token') === 'xxxx') { // 符合条件,放行进入下一路由 next() } else { console.log('校验失败') } } }) // 使用全局前置路由守卫修改页面标题 router.afterEach((to, form, next) => { // 判断即将进入的页面路由元信息中是否有title属性 if (form.meta.title) { document.title = to.meta.title // 修改网页标题 } })
边栏推荐
- pytest合集(7)— 参数化
- Hj37 statistics of the total number of rabbits per month Fibonacci series
- Flink real-time warehouse DWD layer (order placing multiple tables to realize join operation) template code
- 1172. 餐盘栈 有序列表+栈
- 实现改变一段文字的部分颜色效果
- ECCV 2022 lightweight model frame Parc net press apple mobilevit code and paper Download
- Federal learning backdoor attack summary (2019-2022)
- Leetcode-1331: array ordinal conversion
- Is online legend software testing training really so black hearted? Are they all scams?
- 建木持续集成平台v2.5.2发布
猜你喜欢

基于C语言设计的学籍管理系统

buck电路boot和ph引脚实测

IDEA找不到Database解决方法

Leetcode-592: fraction addition and subtraction

微信小程序的反编译

MySQL 有这一篇就够(呕心狂敲37k字,只为博君一点赞!!!)

MVFuseNet:Improving End-to-End Object Detection and Motion Forecasting through Multi-View Fusion of

Flink实时仓库-DWD层(交易域-加购维度退化处理)模板代码

ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘解决方法

Vite3.0都发布了,你还能卷得动吗(新特性一览)
随机推荐
上采样之反卷积操作
外包干了3年,跳槽后转自动化测试工资是原来的2倍,秘诀原来是......
基于C语言设计的学籍管理系统
个人博客系统(附源码)
JS 鸡生蛋与蛋生鸡问题,Object与Function究竟谁出现的更早?Function算不算Function的实例?
聊天机器人有何用处?有何类型?看完这些就明白了!
Why does ETL often become ELT or even let?
Relative date used by filter in salesforce
Simulation volume leetcode [normal] 061. rotating linked list
Student achievement ranking system based on C language design
Can MySQL export tables regularly?
gin 参数验证
Flink实时仓库-DWD层(交易域-加购维度退化处理)模板代码
gin 模版
gin 服务退出
pytest合集(7)— 参数化
Cesium reflection
后缀自动机(SAM)讲解 + Luogu p3804【模板】后缀自动机 (SAM)
WPF嵌套布局案例
After three years of outsourcing, the salary of automatic testing after job hopping is twice that of the original. The secret is