store 使用publicRoutes报错
来源:8-10 业务落地:定义页面权限控制动作,实现页面权限受控-2
treasure0107
2022-09-28
报错信息:index.js?a18c:1 Uncaught ReferenceError: publicRoutes is not defined
at Module.eval [as publicRoutes] (index.js?a18c:1)
at eval (permission.js?31c2:4)
at Module…/src/store/modules/permission.js (app.js:3274)
at webpack_require (app.js:854)
at fn (app.js:151)
at eval (index.js?4360:1)
at Module…/src/store/index.js (app.js:3250)
at webpack_require (app.js:854)
at fn (app.js:151)
at eval (i18n.js?79fa:1)**
import { publicRoutes, privateRoutes } from '@/router'
console.log(‘publicRoutes’, publicRoutes)
export default {
namespaced: true,
state: {
// 路由表:初始拥有静态路由权限
routes: publicRoutes
}
}
- 私有路由表
*/
export const privateRoutes = [UserManageRouter, RoleListRouter, PermissionList, ArticleRouter]
/**
- 公开路由表
*/
export const publicRoutes = [
{
path: ‘/login’,
name: ‘login’,
component: () => import(’@/views/login/index’)
},
{
path: ‘/’,
redirect: ‘/profile’,
component: layout,
children: [
{
path: ‘/profile’,
name: ‘profile’,
component: () => import(’@/views/profile/index’),
meta: {
title: ‘profile’,
icon: ‘user’
}
},
{
path: ‘/404’,
name: ‘404’,
component: () => import(’@/views/error-page/404’)
},
{
path: ‘/401’,
name: ‘401’,
component: () => import(’@/views/error-page/401’)
}
]
}
]
写回答
1回答
-
treasure0107
提问者
2022-09-28
为什么在mian.js
import store from './store'
import router from './router'
store为什么要先引入
012022-09-28
相似问题