mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-12 12:25:16 +08:00
39 lines
651 B
Markdown
39 lines
651 B
Markdown
# 延迟单项(仅叶子节点)
|
|
```html
|
|
<n-cascader
|
|
v-model="value"
|
|
placeholder="请选些什么"
|
|
lazy
|
|
:on-load="handleLoad"
|
|
/>
|
|
```
|
|
```js
|
|
function genChildren (option) {
|
|
const children = []
|
|
const label = option.label || 'root'
|
|
for (let i = 0; i <= option.depth; ++i) {
|
|
children.push({
|
|
label: label + '_' + i,
|
|
value: label + '_' + i,
|
|
isLeaf: option.depth === 3
|
|
})
|
|
}
|
|
return children
|
|
}
|
|
|
|
export default {
|
|
data () {
|
|
return {
|
|
value: null
|
|
}
|
|
},
|
|
methods: {
|
|
handleLoad (option, resolve) {
|
|
window.setTimeout(() => {
|
|
resolve(genChildren(option))
|
|
}, 1000)
|
|
}
|
|
}
|
|
}
|
|
```
|