vue cli+element ui顶部导航栏切换
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
·
vue cli+element ui顶部导航栏切换
效果

实现
表单样式
说明:router属性很重要,default-active="this.$route.path"也很重要。
<el-menu
:default-active="this.$route.path"
class="el-menu-demo"
mode="horizontal"
@select="handleSelect"
router
background-color="#fff"
text-color="#333"
active-text-color="#0084ff"
>
<el-menu-item v-for="(item,i) in navList" :key="i" :index="item.name">
<template slot="title">
<span> {{ item.navItem }}</span>
</template>
</el-menu-item>
</el-menu>
<el-main class="detailed-content">
<router-view />
</el-main>
javascript
/report是导航栏所在的页面,即report.vue,因为想让导航栏点击后还在本页面中,加了一个report作前缀防止跳转。
<script>
export default {
data() {
return {
navList:[
{name:'/report/companyBackground', navItem:'公司背景'},
{name:'/report/companyRisk',navItem:'司法风险'},
{name:'/report/companyManager',navItem:'经营风险'},
]
}
},
methods: {
handleSelect(key, keyPath) {
console.log(key, keyPath);
}
}
}
</script>
路由
redirect为report打开后默认显示的页面
{
name: 'report',
path: '/report',
component: report,
redirect: '/report/companyBackground',
children: [
{
name: 'companyBackground',
path: '/report/companyBackground',
component: companyBackground
},
{
name: 'companyRisk',
path: '/report/companyRisk',
component: companyRisk
},
{
name: 'companyManager',
path: '/report/companyManager',
component: companyManager
}
]
}
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:4 个月前 )
c345bb45
1 年前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)