2
2
<div v-if =" !item.hidden&&item.children" class =" menu-wrapper" >
3
3
4
4
<template v-if =" hasOneShowingChild (item .children ,item ) && (! onlyOneChild .children || onlyOneChild .noShowingChildren )&&! item .alwaysShow " >
5
- <a :href = " onlyOneChild.path " target = " _blank " @click = " clickLink (onlyOneChild.path,$event )" >
5
+ <app-link :to = " resolvePath (onlyOneChild.path)" >
6
6
<el-menu-item :index =" resolvePath(onlyOneChild.path)" :class =" {'submenu-title-noDropdown':!isNest}" >
7
7
<item v-if =" onlyOneChild.meta" :icon =" onlyOneChild.meta.icon||item.meta.icon" :title =" generateTitle(onlyOneChild.meta.title)" />
8
8
</el-menu-item >
9
- </a >
9
+ </app-link >
10
10
</template >
11
11
12
12
<el-submenu v-else :index =" item.name||item.path" >
23
23
:base-path =" resolvePath(child.path)"
24
24
class =" nest-menu" />
25
25
26
- <a v-else :href = " child.path" :key =" child.name" target = " _blank " @click = " clickLink(child.path,$event) " >
26
+ <app-link v-else :to = " resolvePath( child.path) " :key =" child.name" >
27
27
<el-menu-item :index =" resolvePath(child.path)" >
28
28
<item v-if =" child.meta" :icon =" child.meta.icon" :title =" generateTitle(child.meta.title)" />
29
29
</el-menu-item >
30
- </a >
30
+ </app-link >
31
31
</template >
32
32
</el-submenu >
33
33
@@ -39,10 +39,11 @@ import path from 'path'
39
39
import { generateTitle } from ' @/utils/i18n'
40
40
import { validateURL } from ' @/utils/validate'
41
41
import Item from ' ./Item'
42
+ import AppLink from ' ./Link'
42
43
43
44
export default {
44
45
name: ' SidebarItem' ,
45
- components: { Item },
46
+ components: { Item, AppLink },
46
47
props: {
47
48
// route object
48
49
item: {
@@ -89,18 +90,14 @@ export default {
89
90
return false
90
91
},
91
92
resolvePath (routePath ) {
93
+ if (this .isExternalLink (routePath)) {
94
+ return routePath
95
+ }
92
96
return path .resolve (this .basePath , routePath)
93
97
},
94
98
isExternalLink (routePath ) {
95
99
return validateURL (routePath)
96
100
},
97
- clickLink (routePath , e ) {
98
- if (! this .isExternalLink (routePath)) {
99
- e .preventDefault ()
100
- const path = this .resolvePath (routePath)
101
- this .$router .push (path)
102
- }
103
- },
104
101
generateTitle
105
102
}
106
103
}
0 commit comments