Commit 7efa409a by Sendya

fixed: menu 3 children selected

parent f9e96cee
...@@ -122,7 +122,12 @@ export default { ...@@ -122,7 +122,12 @@ export default {
}, },
updateMenu () { updateMenu () {
let routes = this.$route.matched.concat() let routes = this.$route.matched.concat()
this.selectedKeys = [ routes.pop().path ] if (routes.length >= 3 && this.$route.meta.hidden) {
routes.pop()
this.selectedKeys = [ routes[1].path ]
} else {
this.selectedKeys = [ routes.pop().path ]
}
let openKeys = [] let openKeys = []
routes.forEach((item) => { routes.forEach((item) => {
openKeys.push(item.path) openKeys.push(item.path)
......
...@@ -244,42 +244,51 @@ export const asyncRouterMap = [ ...@@ -244,42 +244,51 @@ export const asyncRouterMap = [
path: '/account', path: '/account',
component: Layout, component: Layout,
name: 'account', name: 'account',
meta: { title: '个人页', icon: 'user' }, meta: { title: '个人页', icon: 'user', keepAlive: true },
children: [ children: [
{ {
path: 'center', path: '/account/center',
name: 'center', name: 'center',
component: () => import('@/views/account/Index'), component: () => import('@/views/account/Index'),
meta: { title: '个人中心' } meta: { title: '个人中心', keepAlive: true }
}, },
{ {
path: 'settings', path: '/account/settings',
name: 'settings', name: 'settings',
component: () => import('@/views/account/Index'), component: () => import('@/views/account/Index'),
meta: { title: '个人设置', hideHeader: true }, meta: { title: '个人设置', hideHeader: true, keepAlive: true },
redirect: '/account/settings/base', redirect: '/account/settings/base',
alwaysShow: true, alwaysShow: true,
children: [ children: [
{ {
path: 'base', path: '/account/settings/base',
name: 'BaseSettings', name: 'BaseSettings',
component: () => import('@/views/account/BaseSetting'), component: () => import('@/views/account/BaseSetting'),
hidden: true, meta: { title: '基本设置', hidden: true, keepAlive: true }
meta: { title: '基本设置' }
}, },
{ {
path: 'security', path: '/account/settings/security',
name: 'SecuritySettings', name: 'SecuritySettings',
component: () => import('@/views/account/Security'), component: () => import('@/views/account/Security'),
hidden: true, meta: { title: '安全设置', hidden: true, keepAlive: true }
meta: { title: '安全设置' }
}, },
{ {
path: 'custom', path: '/account/settings/custom',
name: 'CustomSettings', name: 'CustomSettings',
component: () => import('@/views/account/Custom'), component: () => import('@/views/account/Custom'),
hidden: true, meta: { title: '个性化设置', hidden: true, keepAlive: true }
meta: { title: '个性化设置' } },
{
path: '/account/settings/binding',
name: 'BindingSettings',
component: () => import('@/views/account/Binding'),
meta: { title: '账户绑定', hidden: true, keepAlive: true }
},
{
path: '/account/settings/notification',
name: 'NotificationSettings',
component: () => import('@/views/account/Notification'),
meta: { title: '新消息通知', hidden: true, keepAlive: true }
}, },
] ]
}, },
......
<template>
<a-list
itemLayout="horizontal"
:dataSource="data"
>
</a-list>
</template>
<script>
export default {
data () {
return {
}
},
methods: {
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
<template> <template>
<a-card :bordered="false" :bodyStyle="{ padding: '16px 0' }"> <a-card :bordered="false" :bodyStyle="{ padding: '16px 0', height: '100%' }" :style="{ height: '100%' }">
<div class="account-settings-info-main"> <div class="account-settings-info-main">
<div class="account-settings-info-left"> <div class="account-settings-info-left">
<a-menu <a-menu
mode="inline" mode="inline"
:defaultSelectedKeys="['1']" :style="{ border: '0' }"
:defaultSelectedKeys="defaultSelectedKeys"
type="inner" type="inner"
@openChange="onOpenChange" @openChange="onOpenChange"
> >
<a-menu-item key="1"> <a-menu-item key="/account/settings/base">
<router-link :to="{ name: 'BaseSettings' }"> <router-link :to="{ name: 'BaseSettings' }">
基本设置 基本设置
</router-link> </router-link>
</a-menu-item> </a-menu-item>
<a-menu-item key="2"> <a-menu-item key="/account/settings/security">
<router-link :to="{ name: 'SecuritySettings' }"> <router-link :to="{ name: 'SecuritySettings' }">
安全设置 安全设置
</router-link> </router-link>
</a-menu-item> </a-menu-item>
<a-menu-item key="3"> <a-menu-item key="/account/settings/custom">
<router-link :to="{ name: 'CustomSettings' }"> <router-link :to="{ name: 'CustomSettings' }">
个性化 个性化
</router-link> </router-link>
</a-menu-item> </a-menu-item>
<a-menu-item key="4"> <a-menu-item key="/account/settings/binding">
账户绑定 <router-link :to="{ name: 'BindingSettings' }">
账户绑定
</router-link>
</a-menu-item> </a-menu-item>
<a-menu-item key="5"> <a-menu-item key="/account/settings/notification">
新消息通知 <router-link :to="{ name: 'NotificationSettings' }">
新消息通知
</router-link>
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</div> </div>
...@@ -52,6 +57,8 @@ ...@@ -52,6 +57,8 @@
}, },
data () { data () {
return { return {
defaultSelectedKeys: [],
// cropper // cropper
preview: {}, preview: {},
option: { option: {
...@@ -74,12 +81,16 @@ ...@@ -74,12 +81,16 @@
} }
}, },
created () { created () {
this.updateMenu()
}, },
methods: { methods: {
onOpenChange (openKeys) { onOpenChange (openKeys) {
}, },
updateMenu () {
let routes = this.$route.matched.concat()
this.defaultSelectedKeys = [ routes.pop().path ]
}
}, },
} }
</script> </script>
......
<template>
<a-list
itemLayout="horizontal"
:dataSource="data"
>
</a-list>
</template>
<script>
export default {
data () {
return {
}
},
methods: {
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment