@@ -8,7 +8,8 @@ const sidebarMenus = [
8
8
label: ' 我的作品' ,
9
9
value: ' workManager' ,
10
10
antIcon: ' bars' ,
11
- key: ' 1'
11
+ key: ' 1' ,
12
+ routerName: ' work-manager-list'
12
13
},
13
14
{
14
15
label: ' 数据中心' ,
@@ -22,12 +23,6 @@ const sidebarMenus = [
22
23
antIcon: ' snippets' ,
23
24
key: ' 2-1' ,
24
25
routerName: ' form-stat'
25
- },
26
- {
27
- label: ' 表单统计' ,
28
- value: ' formData' ,
29
- antIcon: ' snippets' ,
30
- key: ' 2-2'
31
26
}
32
27
]
33
28
},
@@ -58,6 +53,32 @@ export default {
58
53
// PreView,
59
54
// Sidebar
60
55
},
56
+ methods: {
57
+ renderSidebar (menus ) {
58
+ const renderLabel = menu => menu .routerName ? < router- link to= {{ name: menu .routerName }} > {menu .label }< / router- link> : menu .label
59
+
60
+ return menus .map (menu => (
61
+ menu .children
62
+ ? (
63
+ < a- sub- menu key= {menu .key }>
64
+ < span slot= " title" >< a- icon type= {menu .antIcon } / > {menu .label }< / span>
65
+ {
66
+ (menu .children ).map (submenu => (
67
+ < a- menu- item key= {submenu .key }> {renderLabel (submenu)}< / a- menu- item>
68
+ ))
69
+ }
70
+ < / a- sub- menu>
71
+ )
72
+ : (
73
+ < a- menu- item key= {menu .key }>
74
+ < a- icon type= {menu .antIcon }>< / a- icon>
75
+ {/** 这边有个疑惑,不知是否为 antd-vue 的 bug,需要用 span 包裹,否则不会显示 label */ }
76
+ < span> {renderLabel (menu)}< / span>
77
+ < / a- menu- item>
78
+ )
79
+ ))
80
+ }
81
+ },
61
82
render (h ) {
62
83
return (
63
84
< a- layout id= " luban-work-manager-layout" style= {{ height: ' 100vh' }}>
@@ -84,25 +105,7 @@ export default {
84
105
defaultOpenKeys= {[' 1' , ' 2' , ' 3' ]}
85
106
style= " height: 100%"
86
107
>
87
- {
88
- sidebarMenus .map (menu => (
89
- menu .children
90
- ? < a- sub- menu key= {menu .key }>
91
- < span slot= " title" >< a- icon type= {menu .antIcon } / > {menu .label }< / span>
92
- {
93
- (menu .children ).map (submenu => (
94
- < a- menu- item key= {submenu .key }>
95
- { submenu .routerName ? < router- link to= {{ name: submenu .routerName }}> {submenu .label }< / router- link> : submenu .label }
96
- < / a- menu- item>
97
- ))
98
- }
99
- < / a- sub- menu>
100
- : < a- menu- item key= {menu .key }>
101
- < a- icon type= {menu .antIcon } / >
102
- < span> {menu .label }< / span>
103
- < / a- menu- item>
104
- ))
105
- }
108
+ {this .renderSidebar (sidebarMenus)}
106
109
< / a- menu>
107
110
< / a- layout- sider>
108
111
< a- layout style= " padding: 0 24px 24px" >
0 commit comments