跳到主要内容

meta

2023年05月25日
柏拉文
越努力,越幸运

一、认识


meta 为路由元信息。有时,你可能希望将任意信息附加到路由上,如过渡名称、谁可以访问路由等。这些事情可以通过接收属性对象的meta属性来实现,并且它可以在路由地址和导航守卫上都被访问到。

二、语法


2.1 配置

const routes = [
{
path: '/',
name: 'home',
component: HomeView,
meta: {
icon: "",
auth: [],
}
},
{
path: '/about',
name: 'about',
component: () => import('../views/AboutView.vue'),
meta: {
icon: "",
auth: [],
}
},
]

2.2 访问

to.meta.icon 

to.meta.auth