Vue el-menu-item路由跳转
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue
免费下载资源
·
import Vue from 'vue'
import VueRouter from 'vue-router'
// import HomeView from '../views/HomeView.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'home',
component: () => import(/* webpackChunkName: "about" */ '../views/LoginView.vue')
},
{
path: '/login',
name: 'login',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/LoginView.vue')
},
{
path: '/adminLogin',
name: 'adminLogin',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AdminLoginView.vue')
},
{
path: '/adminMain',
// name: 'adminMain',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AdminMainView.vue'),
children:[
{
path: 'about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
},
{
path: 'user',
name: 'user',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/UserView.vue')
}
]
}
,
// {
// path: '/about',
// name: 'about',
// // route level code-splitting
// // this generates a separate chunk (about.[hash].js) for this route
// // which is lazy-loaded when the route is visited.
// component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
// },
{
path: '/main',
name: 'main',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/MainView.vue')
},
{
path: '/reserve',
name: 'reserve',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/ReserveView.vue')
},
{
path: '/register',
name: 'register',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/RegisterView.vue')
},
{
path: '/personalinformation',
name: 'personalinformation',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/PersonalInformationView.vue')
},
{
path: '/*',
name: '404',
component: () => import(/* webpackChunkName: "about" */ '../views/Page404View.vue')
}
]
const router = new VueRouter({
routes
})
router.beforeEach((to, form, next) => {
let flag = sessionStorage.getItem("username");
if (to.path == "/" || to.path == "/login" || to.path == "/register" || to.path == "/main" ||to.path == "adminLogin") {
next();
} else {
// localStorage.getItem("token")
if (to.meta.requireAuth == true) {
if (!flag) {
next("/login")
}
} else {
next()
}
}
})
export default router
<template>
<el-container>
<el-aside width="200px">
<h1>管理员登录</h1>
<hr>
<el-menu :default-active="this.$router.path" class="el-menu-vertical-demo" @select="selectMenuItem"
:collapse="isCollapse" background-color="#001529" text-color="#fff" active-text-color="#ffd04b" router>
<!-- <el-menu-item index="/adminMain/heros">
<i class="el-icon-menu"></i>
<span slot="title">英雄资料</span>
</el-menu-item>
<el-menu-item index="/adminMain/summoners">
<i class="el-icon-document"></i>
<span slot="title">技能资料</span>
</el-menu-item> -->
<el-menu-item index="/adminMain/about">
<i class="el-icon-setting"></i>
<span slot="title">订单管理</span>
</el-menu-item>
<!-- 用户信息 -->
<!-- <router-link exact to="/adminMain/user">王子健</router-link>
<router-link exact to="/adminMain/about">王子健</router-link> -->
<el-menu-item index="/adminMain/user">
<i class="el-icon-setting"></i>
<span slot="title">用户信息</span>
</el-menu-item>
</el-menu>
<!-- <router-link to="/page404">首页</router-link> -->
</el-aside>
<el-container>
<el-header>Header</el-header>
<el-main>
<router-view/>
</el-main>
</el-container>
</el-container>
</template>
GitHub 加速计划 / vu / vue
207.54 K
33.66 K
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:2 个月前 )
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 4 个月前
e428d891
Updated Browser Compatibility reference. The previous currently returns HTTP 404. 5 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)