请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

store 使用publicRoutes报错

报错信息: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’)
    }
    ]
    }
    ]

正在回答 回答被采纳积分+3

插入代码

1回答

提问者 treasure0107 2022-09-28 11:40:22

为什么在mian.js 

import store from './store'

import router from './router'

store为什么要先引入

0 回复 有任何疑惑可以回复我~
  • Sunday #1
    先引入可先生成 store 实例
    回复 有任何疑惑可以回复我~ 2022-09-28 21:43:09
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号