新增:根据当前路由自动展开菜单

This commit is contained in:
chenghx
2018-08-02 17:59:42 +08:00
parent 0aaf3cf893
commit f5b569f170
6 changed files with 114 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
<template>
<div>
<a-card style="" :bordered="false">
bbb
</a-card>
</div>
</template>
<script>
import ACard from 'vue-antd-ui/es/card/Card'
export default {
name: 'ApplicationList',
components: {ACard}
}
</script>
<style scoped>
</style>

View File

@@ -1,7 +1,7 @@
<template>
<div>
<a-card style="" :bordered="false">
aaaa
</a-card>
</div>
</template>

View File

@@ -0,0 +1,19 @@
<template>
<div>
<a-card style="" :bordered="false">
ccc
</a-card>
</div>
</template>
<script>
import ACard from 'vue-antd-ui/es/card/Card'
export default {
name: 'ProjectList',
components: {ACard}
}
</script>
<style scoped>
</style>

View File

@@ -5,7 +5,7 @@
<a-input-search style="width: 522px" placeholder="请输入..." size="large" enterButton="搜索" />
</div>
<div style="padding: 0 24px">
<a-tabs :tabBarStyle="{margin: 0}">
<a-tabs :tabBarStyle="{margin: 0}" @change="navigate" :activeKey="activeKey">
<a-tab-pane tab="文章" key="1"></a-tab-pane>
<a-tab-pane tab="应用" key="2"></a-tab-pane>
<a-tab-pane tab="项目" key="3"></a-tab-pane>
@@ -29,7 +29,46 @@ const ATabPane = ATabs.TabPane
export default {
name: 'SearchLayout',
components: {ATabPane, ATabs, AInputSearch, AButton, AInputGroup, AInput}
components: {ATabPane, ATabs, AInputSearch, AButton, AInputGroup, AInput},
data () {
return {
activeKey: ''
}
},
watch: {
'$route': (val) => {
switch (val.path) {
case '/list/search/article':
this.activeKey = '1'
break
case '/list/search/application':
this.activeKey = '2'
break
case '/list/search/project':
this.activeKey = '3'
break
default:
this.activeKey = '1'
}
}
},
methods: {
navigate (key) {
switch (key) {
case '1':
this.$router.push('/list/search/article')
break
case '2':
this.$router.push('/list/search/application')
break
case '3':
this.$router.push('/list/search/project')
break
default:
this.$router.push('/workplace')
}
}
}
}
</script>