From 417f7d5f7b8d3df37cfa74ef3955bca117e14fbb Mon Sep 17 00:00:00 2001 From: chenghx Date: Mon, 23 Jul 2018 13:44:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4GloablMenu=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E3=80=81=E8=8F=9C=E5=8D=95=E4=BC=98=E5=8C=96=EF=BC=9A=E5=8F=AA?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E5=BD=93=E5=89=8D=E7=88=B6=E7=BA=A7=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/GloablLayout.vue | 3 -- src/components/layout/GloablMenu.vue | 57 -------------------------- src/components/menu/menu.js | 20 ++++++++- 3 files changed, 19 insertions(+), 61 deletions(-) delete mode 100644 src/components/layout/GloablMenu.vue diff --git a/src/components/layout/GloablLayout.vue b/src/components/layout/GloablLayout.vue index d365217..2404dfc 100644 --- a/src/components/layout/GloablLayout.vue +++ b/src/components/layout/GloablLayout.vue @@ -7,7 +7,6 @@

Vue Ant Pro

- @@ -24,7 +23,6 @@ import ALayout from 'vue-antd-ui/es/layout' import GloablHeader from './GloablHeader' import AIcon from 'vue-antd-ui/es/icon/icon' -import GloablMenu from './GloablMenu' import IMenu from '../menu/menu' const ALayoutSider = ALayout.Sider @@ -38,7 +36,6 @@ let menuData = [] export default { name: 'GloablLayout', components: { - GloablMenu, AIcon, GloablHeader, ALayout, diff --git a/src/components/layout/GloablMenu.vue b/src/components/layout/GloablMenu.vue deleted file mode 100644 index 89b01fa..0000000 --- a/src/components/layout/GloablMenu.vue +++ /dev/null @@ -1,57 +0,0 @@ - - - - - diff --git a/src/components/menu/menu.js b/src/components/menu/menu.js index d335767..e448751 100644 --- a/src/components/menu/menu.js +++ b/src/components/menu/menu.js @@ -44,6 +44,12 @@ export default { default: 'inline' } }, + data () { + return { + rootSubmenuKeys: ['/form', '/list', '/detail', '/exception', '/result'], + openKeys: ['/form'] + } + }, methods: { renderIcon: function (h, icon) { return icon === 'none' ? null @@ -103,6 +109,14 @@ export default { menuArr.push(this2_.renderItem(h, menu, '0', i)) }) return menuArr + }, + onOpenChange (openKeys) { + const latestOpenKey = openKeys.find(key => this.openKeys.indexOf(key) === -1) + if (this.rootSubmenuKeys.indexOf(latestOpenKey) === -1) { + this.openKeys = openKeys + } else { + this.openKeys = latestOpenKey ? [latestOpenKey] : [] + } } }, render (h) { @@ -112,7 +126,11 @@ export default { props: { theme: this.$props.theme, mode: this.$props.mode, - inlineCollapsed: false + inlineCollapsed: false, + openKeys: this.openKeys + }, + on: { + openChange: this.onOpenChange } }, this.renderMenu(h, this.menuData) )