后台中src-router-index.js文件详情
Posted 缔造
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了后台中src-router-index.js文件详情相关的知识,希望对你有一定的参考价值。
后台中src-router-index.js文件详情
import Vue from ‘vue‘ import VueRouter from ‘vue-router‘ // import Login from ‘../components/Login.vue‘ const Login = () => import(/* webpackChunkName:"login_Index_Welcome" */ ‘../components/Login.vue‘) const Index = () => import(/* webpackChunkName:"login_Index_Welcome" */ ‘../components/index.vue‘) const Welcome = () => import(/* webpackChunkName:"login_Index_Welcome" */ ‘../components/welcome.vue‘) // import Index from ‘../components/index.vue‘ // import Welcome from ‘../components/welcome.vue‘ // import Users from ‘../components/user/users.vue‘ const Users = () => import(/* webpackChunkName:"user" */ ‘../components/user/users.vue‘) // import roles from ‘../components/power/roles.vue‘ // import rights from ‘../components/power/rights.vue‘ const roles = () => import(/* webpackChunkName:"power" */ ‘../components/power/roles.vue‘) const rights = () => import(/* webpackChunkName:"power" */ ‘../components/power/rights.vue‘) // import Goods from ‘../components/goods/goods.vue‘ // import Categories from ‘../components/goods/categories.vue‘ // import Params from ‘../components/goods/params.vue‘ // import lloo from ‘../components/goods/lloo.vue‘ const Goods = () => import(/* webpackChunkName:"goods" */ ‘../components/goods/goods.vue‘) const Categories = () => import(/* webpackChunkName:"goods" */ ‘../components/goods/categories.vue‘) const Params = () => import(/* webpackChunkName:"goods" */ ‘../components/goods/params.vue‘) const lloo = () => import(/* webpackChunkName:"goods" */ ‘../components/goods/lloo.vue‘) // import Orders from ‘../components/orders/orders.vue‘ const Orders = () => import(/* webpackChunkName:"orders" */ ‘../components/orders/orders.vue‘) // import Reports from ‘../components/repots/reports.vue‘ const Reports = () => import(/* webpackChunkName:"repots" */ ‘../components/repots/reports.vue‘) // import Meimei from ‘../components/meimei/meimei.vue‘ const Meimei = () => import(/* webpackChunkName:"meimei" */ ‘../components/meimei/meimei.vue‘) Vue.use(VueRouter) const routes = [{ path: ‘/‘, redirect: ‘/Login‘ }, { path: ‘/login‘, component: Login }, { path: ‘/index‘, component: Index, redirect: ‘/welcome‘, children: [ { path: ‘/welcome‘, component: Welcome }, { path: ‘/users‘, component: Users }, { path: ‘/roles‘, component: roles }, { path: ‘/rights‘, component: rights }, { path: ‘/goods‘, component: Goods }, { path: ‘/categories‘, component: Categories }, { path: ‘/params‘, component: Params }, { path: ‘/goods/lloo‘, component: lloo }, { path: ‘/orders‘, component: Orders }, { path: ‘/reports‘, component: Reports }, { path: ‘/meimei‘, component: Meimei } ] } ] const router = new VueRouter({ routes }) // 挂载路由导航守卫 router.beforeEach((to, from, next) => { // to 将要访问的路径 // from 代表从哪个路径跳转而来 // next 是一个函数,表示放行 // next()放行 next(‘/login‘) 强制跳转 if (to.path === ‘/login‘) { return next() } const tokenstr = window.sessionStorage.getItem(‘token‘) if (!tokenstr) { return next(‘/login‘) } next() }) export default router
以上是关于后台中src-router-index.js文件详情的主要内容,如果未能解决你的问题,请参考以下文章
EasyBCD在windows7基础上安装Ubuntu 14.04双系统详