el-menu 导航栏学习(1)

news/2024/7/10 2:45:59 标签: vue, el-menu

最简单的导航栏学习跳转实例效果:

(1)index.js路由配置:

import Vue from 'vue'

import Router from 'vue-router'

import NavMenuDemo from '@/components/NavMenuDemo'

import test1 from '@/components/test1'

import test2 from '@/components/test2'

import test3 from '@/components/test3'

Vue.use(Router)

export default new Router({

  routes: [{

    path: '/',

    name: 'NavMenuDemo',

    component: NavMenuDemo,

    children: [{

      path: '/test1',

      name: 'test1',

      component: test1

    }, {

      path: '/test2',

      name: 'test2',

      component: test2

    }, {

      path: '/test3',

      name: 'test3',

      component: test3

    },]

  }]

})

(2)NavMenuDemo.vue

<template>

  <el-container>

    <el-aside width="200px">

      <el-menu

      default-active="1"

      class="el-menu-vertical-demo"

      router

      >

      <el-menu-item index="/test1"

        @click="$router.push({ path: '/test1' })"

      >

        <i class="el-icon-menu"></i>

        <span slot="title">导航二</span>

      </el-menu-item>

      <el-menu-item index="/test2"

        @click="$router.push({ path: '/test2' })"

      >

        <i class="el-icon-document"></i>

        <span slot="title">导航三</span>

      </el-menu-item>

      <el-menu-item index="/test3"

        @click="$router.push({ path: '/test3' })"

      >

        <i class="el-icon-setting"></i>

        <span slot="title">导航四</span>

      </el-menu-item>

    </el-menu>

    </el-aside>

    <el-main>

      <router-view></router-view>

    </el-main>

  </el-container>

</template>

<style>

  .el-aside {

    height: 100vh;

    text-align: center;

  }

  .el-main {

    background-color: #E9EEF3;

  }

</style>

(3)test1.vue

<template>

    <p>1</p>

</template>

(4)test2.vue

<template>

    <p>2</p>

</template>

最简单的导航栏配置如上图所示,项目中的文件结构如下所示


http://www.niftyadmin.cn/n/5054935.html

相关文章

界面组件DevExpress VCL v23.2新功能预览 - 支持Windows 11

距离DevExpress VCL 下一个主要更新&#xff08;v23.2&#xff09;还有几个月的时间&#xff0c;本文将为大家描述预计在12月初为激活的DevExpress VCL用户发布的一些功能。正如你将在下面看到的&#xff0c;重点领域将继续保持高DPI/SVG和Windows 11的支持。 DevExpress VCL …

软件测试自动化的成本效益分析

随着软件测试技术的发展&#xff0c;人们已经从最初的手工测试转变为手工和自动化技术相结合的测试方法。目前&#xff0c;人们更多的是关心自动化测试框架、自动化测试工具以及脚本研究等技术方面&#xff0c;而在软件自动化测试方案的效益分析方面涉及较少。 软件测试的目的是…

支付宝支付模块开发

生成二维码 使用Hutool工具类生成二维码 引入对应的依赖 <dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.7.5</version> </dependency><dependency><groupId>com.go…

rust引用

一、引用是什么 引用&#xff0c;又叫做借用。是一个指针类型。 引用是指向数据的指针&#xff0c;它允许我们以只读或可变的方式访问数据&#xff0c;而不获取数据的所有权。 编译器静态地保证了引用总是指向有效的对象。也就是说&#xff0c;当存在引用指向一个对象时&#…

黑马JVM总结(二十五)

&#xff08;1&#xff09;字节码指令-cinit 构造方法可以分为两类&#xff0c;一类是cinit 一类init cinit是整个类的构造方法 putstatic&#xff1a;进行static变量的赋值&#xff0c;是到常量池里找到名字一个叫做i的变量 &#xff08;2&#xff09;字节码指令-init in…

Spring Cloud Loadbalancer 实现客户端负载均衡

针对 ribbon 负载均衡组件&#xff0c; 官方提出的替换解决方案是 Spring Cloud Loadbalancer。本次主要通过学习示例介绍了 Spring Cloud Loadbalancer 的基础使用。 1&#xff0c;引入pom <dependency><groupId>org.springframework.cloud</groupId><…

8.3Jmeter使用json提取器提取数组值并循环(循环控制器)遍历使用

Jmeter使用json提取器提取数组值并循环遍历使用 响应返回值例如&#xff1a; {"code":0,"data":{"totalCount":11,"pageSize":100,"totalPage":1,"currPage":1,"list":[{"structuredId":&q…

玩转Mysql系列 - 第24篇:如何正确的使用索引?

这是Mysql系列第24篇。 学习索引&#xff0c;主要是写出更快的sql&#xff0c;当我们写sql的时候&#xff0c;需要明确的知道sql为什么会走索引&#xff1f;为什么有些sql不走索引&#xff1f;sql会走那些索引&#xff0c;为什么会这么走&#xff1f;我们需要了解其原理&#…