vue后台管理项目中菜单栏切换的三种方法
第一种方法:vue嵌套路由(二)
<el-menu :default-active="defaultActive" style="min-height: 100%;" theme="dark" router>
<el-menu-item index="manage">
<i class="el-icon-menu"></i>首页
</el-menu-item>
<el-submenu index=''>
<template slot='title'>
<i class="el-icon-document"></i>用户管理
</template>
<el-menu-item index="userList">用户查询</el-menu-item>
<el-menu-item index="userforbid">封号管理</el-menu-item>
<el-menu-item index="userapply">用户申请</el-menu-item>
</el-submenu>
</el-menu>
<el-col :span="20" style="min-height:100%;background:#F2F4F8">
<router-view></router-view>
</el-col>
在js中
{
path:'/manage',
component: manage,
name:'',
children:[{
path:'/userList',
component:userList,
meta: ['用户列表']
}]
}
当我们点击用户查询时,就会跳转到http://localhost:8080/#/userList
第二种方法点击事件
<el-button :plain="true" type="success" @click="goadd">
goadd(){
this.$router.push({ path: '/addcategory' })
}
第三种方法命名路由:
<div id="app">
<h1>Named Routes</h1>
<p>Current route name: {{ $route.name }}</p>
<ul>
<li><router-link :to="{ name: 'home' }">home</router-link></li>
<li><router-link :to="{ name: 'foo' }">foo</router-link></li>
<li><router-link :to="{ name: 'bar', params: { id: 123 }}">bar</router-link></li>
</ul>
<router-view class="view"></router-view>
</div> <template id='home'>
<div>This is Home</div>
</template> <template id='foo'>
<div>This is Foo</div>
</template> <template id='bar'>
<div>This is Bar {{ $route.params.id }}</div>
</template> const Home = { template: '#home' };
const Foo = { template: '#foo' };
const Bar = { template: '#bar' }; const router = new VueRouter({
routes: [
{ path: '/', name: 'home', component: Home },
{ path: '/foo', name: 'foo', component: Foo },
{ path: '/bar/:id', name: 'bar', component: Bar }
]
}); new Vue({ router:router }).$mount('#app');
第四种方法命名视图:
<div id="app">
<router-link to="/">Go to Foo</router-link>
<router-view class="view one"></router-view>
<router-view class="view two" name="a"></router-view>
<router-view class="view three" name="b"></router-view>
</div> <template id='foo'>
<div>This is Foo</div>
</template> <template id='bar'>
<div>This is Bar {{ $route.params.id }}</div>
</template> <template id='baz'>
<div>This is baz</div>
</template> const Foo = { template: '#foo' };
const Bar = { template: '#bar' };
const Baz = { template: '#baz' }; const router = new VueRouter({
routes: [
{
path: '/',
components: {
default:Foo,
a:Bar,
b:Baz
}
}
]
}); new Vue({ router:router }).$mount('#app');
第五种方法
<div id="app">
<h1>Hello App!</h1>
<p>
<!-- 使用 router-link 组件来导航. -->
<!-- 通过传入 `to` 属性指定链接. -->
<!-- <router-link> 默认会被渲染成一个 `<a>` 标签 -->
<router-link to="/foo">Go to Foo</router-link>
<router-link to="/bar">Go to Bar</router-link>
</p>
<!-- 路由出口 -->
<!-- 路由匹配到的组件将渲染在这里 -->
<router-view></router-view>
</div> <template id='foo'>
<p>this is foo!</p>
</template>
<template id='bar'>
<p>this is bar!</p>
</template> // 1. 定义(路由)组件。
// 可以从其他文件 import 进来
const Foo = { template:'#foo' };
const Bar = { template:'#bar' };
// 2. 定义路由
// 每个路由应该映射一个组件。 其中"component" 可以是
// 通过 Vue.extend() 创建的组件构造器,
// 或者,只是一个组件配置对象。
const routes = [
{ path: '/foo', component: Foo },
{ path: '/bar', component: Bar }
];
// 3. 创建 router 实例,然后传 `routes` 配置
// 你还可以传别的配置参数, 不过先这么简单着吧。
const router = new VueRouter({ routes:routes });
// 4. 创建和挂载根实例。
// 记得要通过 router 配置参数注入路由,
// 从而让整个应用都有路由功能
const app = new Vue({ router:router }).$mount('#app');
引:http://blog.csdn.net/bboyjoe/article/details/52804988
vue后台管理项目中菜单栏切换的三种方法的更多相关文章
- Android中全屏 取消标题栏,TabHost中设置NoTitleBar的三种方法(转)
Android中全屏 取消标题栏,TabHost中设置NoTitleBar的三种方法http://www.cnblogs.com/zdz8207/archive/2013/02/27/android- ...
- Openerp 中打开 URL 的三种 方法
来自:http://shine-it.net/index.php/topic,8013.0.html 最近总结了,Openerp 中打开 URL 的三种 方法: 一.在form view 添加 < ...
- mysql 中添加索引的三种方法
原文:http://www.andyqian.com/2016/04/06/database/mysqleindex/ 在mysql中有多种索引,有普通索引,全文索引,唯一索引,多列索引,小伙伴们可以 ...
- jQuery中detach&&remove&&empty三种方法的区别
jQuery中empty&&remove&&detach三种方法的区别 empty():移除指定元素内部的所有内容,但不包括它本身 remove():移除指定元素内部的 ...
- CSS实现导航条Tab切换的三种方法
前面的话 导航条Tab在页面中非常常见,本文说详细介绍CSS实现导航条Tab的三种方法 布局 根据上图所示,先规定几个定义,上图的模块整体叫做导航,由导航标题和导航内容组成.要实现上图所示的布 ...
- mfc 在VC的两个对话框类中传递参数的三种方法
弄了好久,今天终于把在VC中的对话框类之间传递参数的问题解决了,很开心,记录如下: 1. 我所建立的工程是一个基于MFC对话框的应用程序,一共有三个对话框,第一个对话框为主对话框,所对应的类为CTMD ...
- cocos2dx中创建动画的三种方法
1.最最原始的方法,先创建动画帧,再创建动画打包(animation),再创建动画(animate) 第一步: 创建动画帧:CCSpriteFrame,依赖于原始的资源图片(xx.png,xx.jpg ...
- STM32中AD采样的三种方法分析
在进行STM32F中AD采样的学习中,我们知道AD采样的方法有多种,按照逻辑程序处理有三种方式,一种是查询模式,一种是中断处理模式,一种是DMA模式.三种方法按照处理复杂方法DMA模式处理模式效率最高 ...
- vue中数据请求的三种方法
注意请求可能存在跨域问题,需要去配置好 这三种建议使用axios 1.resource Vue 要实现异步加载需要使用到 vue-resource 库. Vue.js 2.0 版本推荐使用 axios ...
随机推荐
- kerberos协议介绍
一.kerberos认证过程: client向kerberos服务请求,希望获取访问server的权限.kerberos得到了这个消息,首先得判断client是否是可信赖的,也就是白名单黑名单的说法. ...
- nodejs入门安装与调试,mac环境
install nvm (node version manager) 安装nvm curl -o- https://raw.githubusercontent.com/creationix/nvm/v ...
- 【笔记篇】斜率优化dp(四) ZJOI2007仓库建设
传送门戳这里>>> \(n\leq1e6\), 显然还是\(O(n)\)的做法. 这个题有个条件是只能运往编号更大的工厂的仓库, 这也是写出朴素dp的方程的条件. 我们令\(f[i] ...
- Sublime Text自定制代码片段(Code Snippets)
在编写代码的整个过程中,开发人员经常会一次又一次的改写或者重用相同的代码段,消除这种重复过程的方法之一是把我们经常用到的代码保存成代码片段(snippets),这使得我们可以方便的检索和使用它们. 为 ...
- leetcode-90-子集②
题目描述: 方法一:回溯 class Solution: def subsetsWithDup(self, nums: List[int]) -> List[List[int]]: nums.s ...
- Servlet & Filter 执行原理
一.Servlet的两个Map 当请求到达后,web容器是如何查找Servlet的呢?执行流程又是什么? 可能很多人和我一样,只知道在web,xml中配置拦截规则,然后反射+映射就完事了? 当Serv ...
- 【转载】OpenCL实现矩阵相乘
矩阵相乘其实就是前一个矩阵的每一行乘以后一个矩阵的每一列,然后将乘后的每一个数字相加,得到结果矩阵的指定位置的数值.具体算法回顾一下线性代数即可.但是这种行列相乘其实都是独立的,如果是CPU计算必须串 ...
- Git中.gitignore忽略规则
# 此为注释 – 将被 Git 忽略 *.a # 忽略所有 .a 结尾的文件 !lib.a # 但 lib.a 除外 /TODO # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TO ...
- BZOJ 1089 (SCOI 2003) 严格n元树
Description 如果一棵树的所有非叶节点都恰好有n个儿子,那么我们称它为严格n元树.如果该树中最底层的节点深度为d (根的深度为0),那么我们称它为一棵深度为d的严格n元树.例如,深度为2的严 ...
- day 65 Django基础之django分页
Django基础之django分页 一.Django的内置分页器(paginator) view from django.shortcuts import render,HttpRespons ...