2019-10-23 13:56:20 +08:00
|
|
|
# Multiple
|
|
|
|
```html
|
|
|
|
<n-cascader
|
|
|
|
v-model="value"
|
|
|
|
multiple
|
|
|
|
all
|
|
|
|
placeholder="Please Select Something"
|
|
|
|
:options="options"
|
|
|
|
/>
|
|
|
|
```
|
|
|
|
```js
|
2019-08-22 01:24:54 +08:00
|
|
|
function genOptions (depth = 3, iterator = 1, prefix = '') {
|
|
|
|
const length = 12
|
|
|
|
const options = []
|
|
|
|
for (let i = 1; i <= length; ++i) {
|
|
|
|
if (iterator === 1) {
|
|
|
|
options.push({
|
|
|
|
value: `${i}`,
|
|
|
|
label: `${i}`,
|
|
|
|
disabled: i % 5 === 0,
|
|
|
|
children: genOptions(depth, iterator + 1, '' + i)
|
|
|
|
})
|
|
|
|
} else if (iterator === depth) {
|
|
|
|
options.push({
|
|
|
|
value: `${prefix}-${i}`,
|
|
|
|
label: `${prefix}-${i}`,
|
|
|
|
disabled: i % 5 === 0
|
|
|
|
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
options.push({
|
|
|
|
value: `${prefix}-${i}`,
|
|
|
|
label: `${prefix}-${i}`,
|
|
|
|
disabled: i % 5 === 0,
|
|
|
|
children: genOptions(depth, iterator + 1, `${prefix}-${i}`)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return options
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
value: null,
|
|
|
|
options: genOptions()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-23 13:56:20 +08:00
|
|
|
```
|