docs: [el-cascader] add guidance on how to set props (#4689)

This commit is contained in:
Alan Wang 2021-12-10 18:31:15 +08:00 committed by GitHub
parent 6113e9e539
commit d6d74c510a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 13 deletions

View File

@ -49,7 +49,36 @@ cascader/last-level
## Multiple Selection
Set `props.multiple = true` to use multiple selection.
Add `:props="props"` in tag and set data `props = { multiple: true }` to use multiple selection.
Do:
```html
<template>
<el-cascader :props="props" />
</template>
<script lang="ts">
export default {
setup() {
return {
props: {
// props.
multiple: true,
},
}
},
}
</script>
```
Don't do:
```html
<template>
<!-- Object literal binging here is invalid syntax for cascader -->
<el-cascader :props="{ multiple: true }" />
</template>
```
:::demo When using multiple selection, all selected tags will display by default, You can set `collapse-tags = true` to fold selected tags.

View File

@ -3,21 +3,13 @@
<span class="demonstration"
>Select any level of options (Single selection)</span
>
<el-cascader
:options="options"
:props="{ checkStrictly: true }"
clearable
/>
<el-cascader :options="options" :props="props1" clearable />
</div>
<div class="block">
<span class="demonstration"
>Select any level of options (Multiple selection)</span
>
<el-cascader
:options="options"
:props="{ multiple: true, checkStrictly: true }"
clearable
/>
<el-cascader :options="options" :props="props2" clearable />
</div>
</template>
@ -27,6 +19,13 @@ import { defineComponent, reactive, toRefs } from 'vue'
export default defineComponent({
setup() {
const state = reactive({
props1: {
checkStrictly: true,
},
props2: {
multiple: true,
checkStrictly: true,
},
options: [
{
value: 'guide',

View File

@ -14,7 +14,7 @@
<el-cascader
v-model="value"
:options="options"
:props="{ expandTrigger: 'hover' }"
:props="props"
@change="handleChange"
></el-cascader>
</div>
@ -27,6 +27,9 @@ export default defineComponent({
setup() {
const state = reactive({
value: [],
props: {
expandTrigger: 'hover',
},
options: [
{
value: 'guide',

View File

@ -12,7 +12,7 @@
<el-cascader
placeholder="Try searchingL Guide"
:options="options"
:props="{ multiple: true }"
:props="props"
filterable
/>
</div>
@ -24,6 +24,9 @@ import { defineComponent, reactive, toRefs } from 'vue'
export default defineComponent({
setup() {
const state = reactive({
props: {
multiple: true,
},
options: [
{
value: 'guide',