Skip to content

Commit 0f7f234

Browse files
xiaodemenJustineo
authored andcommitted
docs: add load parameters desc, fix demos for cascader
Change-Id: I8ef6a57dc19c40bdfec47f0455e2822fb1f88046
1 parent 53e94b6 commit 0f7f234

File tree

2 files changed

+50
-39
lines changed

2 files changed

+50
-39
lines changed

one/docs/components/cascader.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ function load({
195195
scope: 'descendants' | 'children'
196196
}): Item[] | void | Promise<Item[] | void>
197197
```
198+
199+
`parent` 参数表示当前需要为该项加载更多数据。
200+
201+
`scope` 参数表示加载的数据范围。
202+
203+
+++枚举值
204+
|| 描述 |
205+
| -- | -- |
206+
| `descendants` | 加载所有后代数据。 |
207+
| `children` | 加载子项数据。 |
208+
+++
198209
^^^
199210

200211
### 插槽

one/docs/demo/cascader/lazy.vue

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,35 @@ const options = [
1818
value: '浙江',
1919
options: [
2020
{
21-
label: '威海',
22-
value: '威海'
21+
label: '杭州',
22+
value: '杭州'
2323
},
2424
{
25-
label: '滨州',
26-
value: '滨州'
25+
label: '宁波',
26+
value: '宁波'
2727
},
2828
{
29-
label: '临沂',
30-
value: '临沂'
29+
label: '温州',
30+
value: '温州'
3131
},
3232
{
33-
label: '东营',
34-
value: '东营'
33+
label: '舟山',
34+
value: '舟山'
3535
},
3636
{
37-
label: '济南',
38-
value: '济南'
37+
label: '绍兴',
38+
value: '绍兴'
3939
}
4040
]
4141
},
4242
{
43-
label: '山东',
44-
value: '山东',
43+
label: '上海',
44+
value: '上海',
4545
lazy: true
4646
},
4747
{
48-
label: '上海',
49-
value: '上海',
48+
label: '重庆',
49+
value: '重庆',
5050
disabled: true
5151
},
5252
{
@@ -66,47 +66,47 @@ const options = [
6666
}
6767
]
6868
69-
const hzChildren = [
69+
const pudongChildren = [
7070
{
71-
label: '',
72-
value: ''
71+
label: '张江',
72+
value: '张江'
7373
},
7474
{
75-
label: '',
76-
value: ''
75+
label: '北蔡',
76+
value: '北蔡'
7777
}
7878
]
7979
80-
const getSdChildren = (full) => [
80+
const loadShanghai = (descendants) => [
8181
{
82-
label: '菏泽',
83-
value: '菏泽',
82+
label: '浦东新区',
83+
value: '浦东新区',
8484
lazy: true,
85-
...(full ? { options: hzChildren } : null)
85+
...(descendants ? { options: pudongChildren } : null)
8686
},
8787
{
88-
label: '潍坊',
89-
value: '潍坊',
88+
label: '闵行',
89+
value: '闵行',
9090
options: [
9191
{
92-
label: '',
93-
value: ''
92+
label: '莘庄',
93+
value: '莘庄'
9494
},
9595
{
96-
label: '',
97-
value: ''
96+
label: '颛桥',
97+
value: '颛桥'
9898
}
9999
]
100100
},
101101
{
102-
label: '泰山',
103-
value: '泰山',
102+
label: '宝山',
103+
value: '宝山',
104104
// load no data
105-
...(full ? null : { lazy: true })
105+
...(descendants ? null : { lazy: true })
106106
},
107107
{
108-
label: '烟台',
109-
value: '烟台',
108+
label: '徐汇',
109+
value: '徐汇',
110110
disabled: true
111111
}
112112
]
@@ -125,13 +125,13 @@ export default {
125125
load: ({ parent, scope }) => {
126126
return new Promise((resolve) => {
127127
setTimeout(() => {
128-
let isFull
128+
let descendants
129129
switch (scope) {
130130
case 'children':
131-
isFull = false
131+
descendants = false
132132
break
133133
case 'descendants':
134-
isFull = true
134+
descendants = true
135135
break
136136
default:
137137
console.warn('Not supported.')
@@ -142,8 +142,8 @@ export default {
142142
resolve(
143143
parent
144144
? {
145-
菏泽: hzChildren,
146-
山东: getSdChildren(isFull)
145+
浦东新区: pudongChildren,
146+
上海: loadShanghai(descendants)
147147
}[parent.value]
148148
: undefined
149149
)

0 commit comments

Comments
 (0)