vite + vue3项目开发环境 chrome 71.0.3578.98 报错
依赖版本:
"vite": "2.4.2",
"vue": "^3.1.2",
"vue-router": "^4.0.10"
main.js:
xxx
import router from './router'
xxx
app
.use(store)
.use(router)
.mount('#app')
router/index.js:
import { createRouter, createWebHashHistory } from "vue-router";
import Home from "../views/Home.vue";
const routes = [
{
path: '/',
redirect: '/dashboard'
}, {
path: "/",
name: "Home",
component: Home,
children: [
{
path: "/dashboard",
name: "dashboard",
meta: {
title: '系统首页'
},
component: () => import( /* webpackChunkName: "dashboard" */ "../views/Dashboard.vue")
}, {
path: "/table",
name: "basetable",
meta: {
title: '表格'
},
component: () => import( /* webpackChunkName: "table" */ "../views/BaseTable.vue")
},
xxx
]
}, {
path: "/login",
name: "Login",
meta: {
title: '登录'
},
component: () => import( /* webpackChunkName: "login" */ "../views/Login.vue")
}
];
const router = createRouter({
history: createWebHashHistory(),
routes
});
router.beforeEach((to, from, next) => {
document.title = `${to.meta.title} | vue-manage-system`;
const role = localStorage.getItem('ms_username');
if (!role && to.path !== '/login') {
next('/login');
} else if (to.meta.permission) {
// 如果是管理员权限则可进入,这里只是简单的模拟管理员权限而已
role === 'admin'
? next()
: next('/403');
} else {
next();
}
});
export default router;
报错:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论