关于vue admin element的权限
router/index
export const constantRoutes = [ // ...
{
path: '/',
component: Layout,
redirect: '/company/index'
}
]
/**
* asyncRoutes
* the routes that need to be dynamically loaded based on user roles
*/
export const asyncRoutes = [
// 项目的路由开始
{
path: '/company',
component: Layout,
redirect: '/company/index',
name: 'Company',
meta: {
title: '入驻页',
icon: 'guide',
roles: ['editor']
},
alwaysShow: false,
children: [
{
path: 'index',
component: () => import('@/views/company/index'),
name: 'CompanyIndex',
meta: { title: '欢迎页', icon: 'guide', noCache: true }
},
{
path: 'base',
component: () => import('@/views/company/base'),
name: 'CompanyBase',
hidden: true,
meta: { title: '表单页', icon: 'guide', noCache: false, keepAlive: true } // , roles: ['editor']
},
{
path: 'person',
component: () => import('@/views/company/person'),
name: 'CompanyPerson',
hidden: true,
meta: { title: '自然人页', icon: 'guide', noCache: true }
},
{
path: 'enterprise',
component: () => import('@/views/company/enterprise'),
name: 'CompanyEnterprise',
hidden: true,
meta: { title: '非自然人页', icon: 'guide', noCache: true }
}
]
},
// ....
这个配置写的有毛病吗?为啥meta中一加roles角色设置都无法登陆。提示
TypeError: roles.some is not a function
以下是服务器端的响应
我只是将mock/user下的代码移到服务器上了
回答:
返回的数据里roles
这个格式不对吧,应该是这样:
{ "roles": ["editor"]
}
是一个数组,但你返回的是"['editor']"
,返回了个字符串
以上是 关于vue admin element的权限 的全部内容, 来源链接: utcz.com/p/936416.html