mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
docs: [select-v2] add demo of how to use value-key (#7175)
* docs: [el-select] add demo of how to use value-key * docs: [selectV2] add demo of how to use value-key * Update use-valueKey.vue Co-authored-by: RealityBoy <1923740402@qq.com>
This commit is contained in:
parent
24846102bb
commit
1854891bce
@ -125,6 +125,14 @@ select-v2/remote-search
|
||||
|
||||
:::
|
||||
|
||||
## use value-key
|
||||
|
||||
:::demo when `options.value` is an object, you should set a unique identity key name for value
|
||||
|
||||
select-v2/use-valueKey
|
||||
|
||||
:::
|
||||
|
||||
## SelectV2 Attributes
|
||||
|
||||
| Attribute | Description | Type | Accepted Values | Default |
|
||||
|
28
docs/examples/select-v2/use-valueKey.vue
Normal file
28
docs/examples/select-v2/use-valueKey.vue
Normal file
@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<el-select-v2
|
||||
v-model="value"
|
||||
:options="options"
|
||||
placeholder="Please select"
|
||||
value-key="value.name"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
const initials = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
|
||||
|
||||
const value = ref('')
|
||||
const options = Array.from({ length: 1000 }).map((_, idx) => ({
|
||||
value: {
|
||||
name: `Option ${idx + 1}`,
|
||||
test: `test ${idx % 3}`,
|
||||
},
|
||||
label: `${initials[idx % 10]}${idx}`,
|
||||
}))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.example-showcase .el-select-v2 {
|
||||
margin-right: 20px;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user