| | |
| | | methods: { |
| | | // select menu item |
| | | onOpenChange (openKeys) { |
| | | |
| | | // 在水平模式下时执行,并且不再执行后续 |
| | | if (this.mode === 'horizontal') { |
| | | this.openKeys = openKeys |
| | |
| | | </Item> |
| | | ) |
| | | }, |
| | | handleTitleClick(record,event){ |
| | | this.selectedKeys=[] |
| | | const routes = this.$route.matched.concat() |
| | | const { hidden } = this.$route.meta |
| | | |
| | | if (routes.length >= 3 && hidden) { |
| | | routes.pop() |
| | | this.selectedKeys = [routes[routes.length - 1].path] |
| | | } else { |
| | | if (record.path === '/dashboard/analysis') { |
| | | //如果是首页则直接跳转首页 |
| | | this.selectedKeys = [record] |
| | | } else if (record.children && record.children.length > 0) { |
| | | //如果不是首页且有子菜单则展开点击标题下的所有不含下级菜单的子菜单至导航栏并打开第一个子菜单页面,若子菜单标题下仍有下一级菜单则只需要点击含下级菜单的子菜单标题即可 |
| | | this.selectedKeys = record.children.filter(item => !item.hidden&&!item.children) |
| | | } |
| | | } |
| | | this.$bus.$emit('clickMenuTitleSelected', this.selectedKeys) |
| | | }, |
| | | renderSubMenu (menu) { |
| | | const itemArr = [] |
| | | if (!menu.alwaysShow) { |
| | | menu.children.forEach(item => itemArr.push(this.renderItem(item))) |
| | | } |
| | | return ( |
| | | <SubMenu {...{ key: menu.path }}> |
| | | <SubMenu {...{ key: menu.path }} onTitleClick={this.handleTitleClick.bind(this.$event,menu)}> |
| | | <span slot="title"> |
| | | {this.renderIcon(menu.meta.icon)} |
| | | <span>{menu.meta.title}</span> |