当前位置: 首页 > news >正文

el-menu 导航栏学习(1)

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

(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.lryc.cn/news/179689.html

相关文章:

  • Axios请求封装
  • Pikachu靶场——XXE 漏洞
  • vscode登录租的新服务器
  • Verilog参数定义与仿真模块中的参数修改
  • Android studio升级Giraffe | 2022.3.1 Patch 1踩坑
  • 使用U3D、pico开发VR(二)——添加手柄摇杆控制移动
  • 【FPGA项目】图像采集及显示(2)详细设计方案
  • 查找排序部分习题 242. 有效的字母异位词 74. 搜索二维矩阵 1. 两数之和 167.两数之和 II
  • MATLAB算法实战应用案例精讲-【优化算法】冠状病毒优化算法(COVIDOA)(附MATLAB代码实现)
  • React查询、搜索类功能的实现
  • k8s搭建EFK日志系统
  • LuatOS-SOC接口文档(air780E)-- fonts - 字体库
  • [Java·算法·困难]LeetCode124.二叉树中的最大路径和
  • 【微服务保护】
  • 【MATLAB第78期】基于MATLAB的VMD-SSA-LSTM麻雀算法优化LSTM时间序列预测模型
  • 分类预测 | MATLAB实现SSA-FS-SVM麻雀算法同步优化特征选择结合支持向量机分类预测
  • 唤醒手腕 Matlab 游戏编程常用技术知识点详细教程(更新中)
  • 2023八股每日一题(九月份)
  • 分布式链路追踪--SkyWalking7.0.0+es7.0.0
  • web:[RoarCTF 2019]Easy Calc
  • 【Java每日一题】— —第十七题:杨辉三角(等腰三角形)。(2023.10.01)
  • Ubuntu20.04.1编译qt6.5.3版mysql驱动
  • Stm32_标准库_4_TIM中断_PWM波形_呼吸灯
  • 华为摄像头智能安防监控解决方案
  • The rise of language models
  • Windows下使用VS2010编译出带pdb可调试的FFmpeg库
  • 36.骑士周游算法及其基于贪心算法的优化
  • win安装vscode
  • 【图像分割】图像检测(分割、特征提取)、各种特征(面积等)的测量和过滤(Matlab代码实现)
  • Linux内核存在缺陷发行陷困境