File tree Expand file tree Collapse file tree 2 files changed +50
-39
lines changed Expand file tree Collapse file tree 2 files changed +50
-39
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,17 @@ function load({
195
195
scope : ' descendants' | ' children'
196
196
}): Item [] | void | Promise <Item [] | void >
197
197
```
198
+
199
+ ` parent ` 参数表示当前需要为该项加载更多数据。
200
+
201
+ ` scope ` 参数表示加载的数据范围。
202
+
203
+ ++ + 枚举值
204
+ | 值 | 描述 |
205
+ | -- | -- |
206
+ | ` descendants ` | 加载所有后代数据。 |
207
+ | ` children ` | 加载子项数据。 |
208
+ ++ +
198
209
^^^
199
210
200
211
### 插槽
Original file line number Diff line number Diff line change @@ -18,35 +18,35 @@ const options = [
18
18
value: ' 浙江' ,
19
19
options: [
20
20
{
21
- label: ' 威海 ' ,
22
- value: ' 威海 '
21
+ label: ' 杭州 ' ,
22
+ value: ' 杭州 '
23
23
},
24
24
{
25
- label: ' 滨州 ' ,
26
- value: ' 滨州 '
25
+ label: ' 宁波 ' ,
26
+ value: ' 宁波 '
27
27
},
28
28
{
29
- label: ' 临沂 ' ,
30
- value: ' 临沂 '
29
+ label: ' 温州 ' ,
30
+ value: ' 温州 '
31
31
},
32
32
{
33
- label: ' 东营 ' ,
34
- value: ' 东营 '
33
+ label: ' 舟山 ' ,
34
+ value: ' 舟山 '
35
35
},
36
36
{
37
- label: ' 济南 ' ,
38
- value: ' 济南 '
37
+ label: ' 绍兴 ' ,
38
+ value: ' 绍兴 '
39
39
}
40
40
]
41
41
},
42
42
{
43
- label: ' 山东 ' ,
44
- value: ' 山东 ' ,
43
+ label: ' 上海 ' ,
44
+ value: ' 上海 ' ,
45
45
lazy: true
46
46
},
47
47
{
48
- label: ' 上海 ' ,
49
- value: ' 上海 ' ,
48
+ label: ' 重庆 ' ,
49
+ value: ' 重庆 ' ,
50
50
disabled: true
51
51
},
52
52
{
@@ -66,47 +66,47 @@ const options = [
66
66
}
67
67
]
68
68
69
- const hzChildren = [
69
+ const pudongChildren = [
70
70
{
71
- label: ' 菏 ' ,
72
- value: ' 菏 '
71
+ label: ' 张江 ' ,
72
+ value: ' 张江 '
73
73
},
74
74
{
75
- label: ' 泽 ' ,
76
- value: ' 泽 '
75
+ label: ' 北蔡 ' ,
76
+ value: ' 北蔡 '
77
77
}
78
78
]
79
79
80
- const getSdChildren = (full ) => [
80
+ const loadShanghai = (descendants ) => [
81
81
{
82
- label: ' 菏泽 ' ,
83
- value: ' 菏泽 ' ,
82
+ label: ' 浦东新区 ' ,
83
+ value: ' 浦东新区 ' ,
84
84
lazy: true ,
85
- ... (full ? { options: hzChildren } : null )
85
+ ... (descendants ? { options: pudongChildren } : null )
86
86
},
87
87
{
88
- label: ' 潍坊 ' ,
89
- value: ' 潍坊 ' ,
88
+ label: ' 闵行 ' ,
89
+ value: ' 闵行 ' ,
90
90
options: [
91
91
{
92
- label: ' 潍 ' ,
93
- value: ' 潍 '
92
+ label: ' 莘庄 ' ,
93
+ value: ' 莘庄 '
94
94
},
95
95
{
96
- label: ' 坊 ' ,
97
- value: ' 坊 '
96
+ label: ' 颛桥 ' ,
97
+ value: ' 颛桥 '
98
98
}
99
99
]
100
100
},
101
101
{
102
- label: ' 泰山 ' ,
103
- value: ' 泰山 ' ,
102
+ label: ' 宝山 ' ,
103
+ value: ' 宝山 ' ,
104
104
// load no data
105
- ... (full ? null : { lazy: true })
105
+ ... (descendants ? null : { lazy: true })
106
106
},
107
107
{
108
- label: ' 烟台 ' ,
109
- value: ' 烟台 ' ,
108
+ label: ' 徐汇 ' ,
109
+ value: ' 徐汇 ' ,
110
110
disabled: true
111
111
}
112
112
]
@@ -125,13 +125,13 @@ export default {
125
125
load : ({ parent, scope }) => {
126
126
return new Promise ((resolve ) => {
127
127
setTimeout (() => {
128
- let isFull
128
+ let descendants
129
129
switch (scope) {
130
130
case ' children' :
131
- isFull = false
131
+ descendants = false
132
132
break
133
133
case ' descendants' :
134
- isFull = true
134
+ descendants = true
135
135
break
136
136
default :
137
137
console .warn (' Not supported.' )
@@ -142,8 +142,8 @@ export default {
142
142
resolve (
143
143
parent
144
144
? {
145
- 菏泽 : hzChildren ,
146
- 山东 : getSdChildren (isFull )
145
+ 浦东新区 : pudongChildren ,
146
+ 上海 : loadShanghai (descendants )
147
147
}[parent .value ]
148
148
: undefined
149
149
)
You can’t perform that action at this time.
0 commit comments