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路由结合的更多相关文章

  1. Vue+ElementUI 导航组件

    创建导航页组件 在components目录下新建一个navigation目录,在Navi目录中新建一个名为Navi.vue的组件.至此我们的目录应该是如下图所示: 然后我们修改main.js文件,修改 ...

  2. element-ui使用导航栏跳转路由用法

    element-ui使用导航栏跳转路由用法 最近初学vue,试着做一个小项目熟悉语法与思想,其中使用elemen-ui的导航栏做路由跳转切换页面.下面记录一下学习过程 element-ui引入vue项 ...

  3. elementUI的导航栏怎么根据路由默认选中相关项

    1. <el-menu :default-active="this.$route.path.substr(1)" class="left-nav"> ...

  4. [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 ...

  5. Flutter学习笔记(15)--MaterialApp应用组件及routes路由详解

    如需转载,请注明出处:Flutter学习笔记(15)--MaterialApp应用组件及routes路由详解 最近一段时间生病了,整天往医院跑,也没状态学东西了,现在是好了不少了,也该继续学习啦!!! ...

  6. 01-02 Flutter仿京东商城项目 功能分析、底部导航Tab切换以及路由配置、架构搭建:(Flutter仿京东商城项目 首页布局以及不同终端屏幕适配方案)

    Flutter和Dart交流学习群:交流群:452892873 01Flutter仿京东商城项目 功能分析.底部导航Tab切换以及路由配置.架构搭建 02Flutter仿京东商城项目 首页布局以及不同 ...

  7. 第七节:Vuejs路由交互及后台系统路由案例

    一. 简介 1.路由的概念 路由的本质就是一种对应关系,比如说我们在url地址中输入我们要访问的url地址之后,浏览器要去请求这个url地址对应的资源.那么url地址和真实的资源之间就有一种对应的关系 ...

  8. vue--vue-router 组件映射到路由

    前言 地址栏路由的发展经历了后端路由配置阶段.前后端分离阶段.直至单页面富应用阶段.本文来总结一下 vue-router 的相关知识点和用法. 正文 1.什么是 vue-router 路由 路由就是S ...

  9. 详解Bootstrap导航组件

    在bootstrap框架中将导航独立出来成为一个导航组件,根据不同的版本,可以找到相应的源码: LESS:  navs.less SASS:  _navs.scss 标签形导航,也称选项卡导航 标签形 ...

随机推荐

  1. request方法总结

     1.获得指定的头 String header = response.getHeader("user-agent"); 2.获得所有头的名称 Enumeration<Stri ...

  2. ORA-12541:TNS-12560:ORA-12518:ORA-28040:ORA-01017

    说明 环境(参考): Oracle 12c SQL Developer/Navicat Premium(64位)连接数据库 后续出现的错误代码: ORA-12541: no listener TNS- ...

  3. oracle OCI lob操作

    可以有两种方式来bind lob字段 1)直接绑定lob 值 2)绑定lob locator指针 对于 直接绑定lob值的操作如下 char* sql = "insert into tab_ ...

  4. 滴滴开源 Vue 组件库— cube-ui

    cube-ui 是滴滴去年底开源的一款基于 Vue.js 2.0 的移动端组件库,主要核心目标是做到体验极致.灵活性强.易扩展以及提供良好的周边生态-后编译. 自 17 年 11 月开源至今已有 5 ...

  5. csharp: using using System.Web.Script.Serialization read json

    using System; using System.Data; using System.Configuration; using System.Collections; using System. ...

  6. linux 共享目录

    1. 文件上传遇到多物理机多实例时,怎么处理呢? ftp, 文件同步, 目录共享 这里用目录共享来一把. 2. 操作流程 物理机两台 192.168.1.88  192.168.1.166 2.1 服 ...

  7. JavaScript This -笔记

    参考文章:blog.crimx.com/2016/05/12/understanding-this/ 在es6箭头函数之前this是执行时候确定的,而非定义时候确定.函数都是被调用的,调用时找前面调用 ...

  8. 纯js轮播图

    <div id="wrapper"> <div id="container"> <img src="http://ima ...

  9. Java 之初(1)

    省赛结束之后有相当长一段空闲时间,于是就想先提前自学一点Java语言的知识,在这里纪录一下学习过程,希望能给自学Java的同学提供一点小帮助!(当然,也能方便我以后的复习用^_^) 在学习过程中有什么 ...

  10. C#——Visual Studio项目中的AssemblyInfo.cs文件包含的配置信息

    Visual Studio程序集项目中的AssemblyInfo.cs文件中的内容 using System.Reflection; using System.Runtime.CompilerServ ...