vue使用element实现导航的注意点
<template> <div class="app"> <el-header> <el-menu :default-active="$route.path" router class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#545c64" 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> <div class="line"></div> </el-header> <el-main> <router-view></router-view> </el-main> </div> </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属性直接书写的路由
相关推荐
wikiwater 2020-10-27
IdeaElements 2020-08-19
Sophiego 2020-08-16
Kakoola 2020-08-01
Kakoola 2020-07-29
ELEMENTS爱乐冬雨 2020-07-18
ELEMENTS爱乐小超 2020-07-04
ELEMENTS爱乐小超 2020-07-04
Kakoola 2020-06-28
Feastaw 2020-06-18
Wmeng0 2020-06-14
ELEMENTS爱乐冬雨 2020-06-14
云之高水之远 2020-06-14
哈喽elements 2020-06-14
Feastaw 2020-06-11