Elementui 导航组件和Vuejs路由结合
Elementui 导航组件和Vuejs路由结合, 达到点击导航切换路由,根据路由定位导航
一下是nav.vue代码,导航数据以json格式配置
<template>
<el-menu :default-active=\"$route.path\"
class=\"el-menu-vertical-demo\"
router=true
@open=\"handleOpen\"
@close=\"handleClose\"
background-color=\"#545c64\"
text-color=\"#fff\"
active-text-color=\"#ffd04b\"
v-bind:aa=\"$route.path\" >
<template v-for=\"item in menuDatas\">
<el-submenu v-if=\"item.children&&item.children.length>0\" v-bind:key=\"item.index\" v-bind:index=\"item.src\">
<template slot=\"title\">
<i class=\"el-icon-location\"></i>
<span >{{ item.title }}</span>
</template>
<el-menu-item-group v-if=\"item.children&&item.children.length>0\" >
<el-menu-item v-for=\"item in item.children\" v-bind:key=\"item.index\" v-bind:index=\"item.src\" >
<span >{{ item.title }}</span>
</el-menu-item>
</el-menu-item-group>
</el-submenu>
<el-menu-item v-else v-bind:key=\"item.index\" v-bind:index=\"item.src\">
<i class=\"el-icon-menu\"></i>
<span >{{ item.title }}</span>
</el-menu-item>
</template> </el-menu> </template> <script>
export default {
name: \"LeechgNav\",
data: function() {
var menuDatas = [
{index:\"1\", type: \"href\", title: \"导航一\", icon: \"\", src: \"/1\", children: [
{index:\"1-2\", type: \"href\", title: \"选项一\", icon: \"\", src: \"/index\", children: [] },
{index:\"1-3\", type: \"href\", title: \"选项二\", icon: \"\", src: \"/lee\", children: [] },
{index:\"1-4\", type: \"href\", title: \"选项三\", icon: \"\", src: \"/lee2\", children: [] }
] },
{index:\"2\", type: \"href\", title: \"导航二\", icon: \"\", src: \"/2\", children: [] },
{index:\"3\", type: \"href\", title: \"导航三\", icon: \"\", src: \"/3\", children: [] },
{index:\"4\", type: \"href\", title: \"导航四\", icon: \"\", src: \"/4\", children: [] }
];
return {
greeting: \"Hello\",
menuDatas
};
}
};
</script>
<style>
.leechg_index {
background-color: red;
color: white;
} .el-row {
margin-bottom: 20px;
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf;
}
.bg-purple {
background: #d3dce6;
}
.bg-purple-light {
background: #e5e9f2;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc;
}
a{
color: white;
text-decoration: none;
color: inherit;
text-decoration: inherit;
}
</style>
Elementui 导航组件和Vuejs路由结合的更多相关文章
- Vue+ElementUI 导航组件
创建导航页组件 在components目录下新建一个navigation目录,在Navi目录中新建一个名为Navi.vue的组件.至此我们的目录应该是如下图所示: 然后我们修改main.js文件,修改 ...
- element-ui使用导航栏跳转路由用法
element-ui使用导航栏跳转路由用法 最近初学vue,试着做一个小项目熟悉语法与思想,其中使用elemen-ui的导航栏做路由跳转切换页面.下面记录一下学习过程 element-ui引入vue项 ...
- elementUI的导航栏怎么根据路由默认选中相关项
1. <el-menu :default-active="this.$route.path.substr(1)" class="left-nav"> ...
- [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined、vuejs路由使用的问题Error in render function
1.[Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined 注意,只要出现Error i ...
- Flutter学习笔记(15)--MaterialApp应用组件及routes路由详解
如需转载,请注明出处:Flutter学习笔记(15)--MaterialApp应用组件及routes路由详解 最近一段时间生病了,整天往医院跑,也没状态学东西了,现在是好了不少了,也该继续学习啦!!! ...
- 01-02 Flutter仿京东商城项目 功能分析、底部导航Tab切换以及路由配置、架构搭建:(Flutter仿京东商城项目 首页布局以及不同终端屏幕适配方案)
Flutter和Dart交流学习群:交流群:452892873 01Flutter仿京东商城项目 功能分析.底部导航Tab切换以及路由配置.架构搭建 02Flutter仿京东商城项目 首页布局以及不同 ...
- 第七节:Vuejs路由交互及后台系统路由案例
一. 简介 1.路由的概念 路由的本质就是一种对应关系,比如说我们在url地址中输入我们要访问的url地址之后,浏览器要去请求这个url地址对应的资源.那么url地址和真实的资源之间就有一种对应的关系 ...
- vue--vue-router 组件映射到路由
前言 地址栏路由的发展经历了后端路由配置阶段.前后端分离阶段.直至单页面富应用阶段.本文来总结一下 vue-router 的相关知识点和用法. 正文 1.什么是 vue-router 路由 路由就是S ...
- 详解Bootstrap导航组件
在bootstrap框架中将导航独立出来成为一个导航组件,根据不同的版本,可以找到相应的源码: LESS: navs.less SASS: _navs.scss 标签形导航,也称选项卡导航 标签形 ...
随机推荐
- 编写DBCP连接池
#配置数据库数据源package com.itang.utils; import java.io.InputStream; import java.sql.Connection; import jav ...
- 五、mybatis集成使用
1.添加依赖 <!-- mybatis-spring集成--> <dependency> <groupId>org.mybatis.spring.boot</ ...
- Java并发编程:CountDownLatch、CyclicBarrier和Semaphore (总结)
下面对上面说的三个辅助类进行一个总结: 1)CountDownLatch和CyclicBarrier都能够实现线程之间的等待,只不过它们侧重点不同: CountDownLatch一般用于某个线程A等待 ...
- 第11章 Media Queries 与Responsive 设计
Media Queries--媒体类型(一) 随着科学技术不断的向前发展,网页的浏览终端越来越多样化,用户可以通过:宽屏电视.台式电脑.笔记本电脑.平板电脑和智能手机来访问你的网站.尽管你无法保证一个 ...
- K2P断流问题
本帖最后由 yufei8051 于 2019-3-15 15:29 编辑 感谢 “zhc887”的指点,把这3个文件删除后(后面大神说不是删除是清除,我直接删掉貌似也正常,建议听大神的)从这两天的使用 ...
- 移动端布局注意事项与less
用Koala实现less的实时编译 1.下载Koala(Koala可以实现实时编译) 2.把CSS文件夹(如index.css,index.less)拖到Koala中 3.点击到需要编译的index. ...
- 配置centos7 网卡
进入root模式,输入 cd /etc/sysconfig/network-scripts/ 按Tab键查看网卡配置文件名称,然后进入编辑: 如: cd /etc/sysconfig/network- ...
- alert 多语言的处理
1. code <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <m ...
- Makefile一 头文件及库搜索路径
头文件及库搜索路径 头文件的搜索路径: 头文件的搜索规则是:找到就使用,停止继续往下寻找 1: #include “mytest.h” 搜索的顺序为: (1)先搜索当前目录 (2)然后搜索编译时 -I ...
- easyui 删除行的时候 引起的 bug
问题场景 easyui 编辑里 有删除行的功能 文档提供的方法如下 $aplgrid为grid 的容器 ind 为当前行的索引 $aplgrid.datagrid('deleteRow', ind); ...