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>

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

相关推荐
PD我是你的真爱粉20 小时前
API 请求封装(Axios + 拦截器 + 错误处理)
前端框架·vue
biyezuopinvip3 天前
基于Spring Boot的投资理财系统设计与实现(毕业论文)
java·spring boot·vue·毕业设计·论文·毕业论文·投资理财系统设计与实现
biyezuopinvip3 天前
基于Spring Boot的投资理财系统设计与实现(任务书)
java·spring boot·vue·毕业设计·论文·任务书·投资理财系统设计与实现
huohuopro3 天前
Vue3 Webview 转 Android 虚拟导航栏遮挡问题记录
android·vue
码界筑梦坊4 天前
332-基于XGBoost与SHAP的可穿戴设备亚健康风险识别系统
python·数据分析·flask·vue·毕业设计
上单带刀不带妹4 天前
【Axios 实战】网络图片地址转 File 对象,附跨域解决方案
开发语言·前端·javascript·vue
SuperEugene4 天前
前端模块化与 import/export入门:从「乱成一团」到「清晰可维护」
前端·javascript·面试·vue
~央千澈~5 天前
优雅草正版授权系统 - 优雅草科技开源2月20日正式发布
python·vue·php·授权验证系统
Roc.Chang6 天前
Vite 启动报错:listen EACCES: permission denied 0.0.0.0:80 解决方案
linux·前端·vue·vite
PD我是你的真爱粉6 天前
Vite 项目搭建与Pinia状态管理
前端框架·vue