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>

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

相关推荐
aXin_ya2 小时前
ElementUI (01):Vue2 项目引入 ElementUI使用
elementui·vue
常宇佳1 天前
vue3 @代指src路径设置
前端·typescript·vue
北城笑笑1 天前
Server 18 ,Nginx + Vite 前端部署排错实战:从 `/api/gpt/chat` 404 到 9012 后端服务的完整定位过程
linux·运维·前端·nginx·ubuntu·vue
小强库计算机毕业设计5 天前
SpringBoot+Vue3 学生宿舍管理系统实战
java·spring boot·后端·vue·学生宿舍管理系统
TELL5217 天前
vue前端架构
vue
南城以南溫暖如初1477 天前
社区健身小程序开发流程详解:技术选型与实施经验分享
java·经验分享·spring boot·mysql·vue·apache
万亿少女的梦1687 天前
基于Spring Boot、Vue与MySQL的私人健身教练预约管理系统设计
java·spring boot·mysql·vue·预约管理
满栀5859 天前
vue动态路由效果
前端·javascript·vue.js·前端框架·vue
碧水澜庭9 天前
头条【vue+fastapi 】全栈教学项目系列之《02_双系统零基础环境搭建手册》
vue·fastapi
DsirNg11 天前
从 `@wheel.prevent.stop` 到事件捕获:一次讲清浏览器事件流与 Vue 事件修饰符
javascript·vue·事件修饰符·事件冒泡·dom 事件·事件捕获·wheel