33游戏网
您的当前位置:首页vue使用element实现导航的分析

vue使用element实现导航的分析

来源:33游戏网


这篇文章主要介绍了关于vue使用element实现导航的分析,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

<template>
 <p class="app">
 <el-header>
 <el-menu :default-active="$route.path" router class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#545c"
 text-color="#fff"
 active-text-color="#ffd04b">
 <el-menu-item index="/Help">帮助</el-menu-item>
 <el-menu-item index="/Central-summary">中心概括</el-menu-item>
 <el-menu-item index="/Flying-Eagle-Academy">飞鹰学苑</el-menu-item>
 <el-menu-item index="/Strategy-comparison">策略对比</el-menu-item>
 <el-menu-item index="/Strategy-backtest">策略回测</el-menu-item>
 <el-menu-item index="/Combined-configuration">组合配置</el-menu-item>
 </el-menu>
 <p class="line"></p>
 </el-header>
 <el-main>
 <router-view></router-view>
 </el-main>
 </p>
</template>
<script>
 export default {
 data() {
 return {
 activeIndex: "1"
 };
 }
 };
</script>

vue中使用element实现导航需要注意三个方面

1.启用vue-router

在el-menu中添加 router

2.刷新页面后,对应menu高亮

更改 :default-active="$route.path"

3.添加各路由

在el-menu-item中的index属性直接书写的路由

显示全文