element-plus/docs/examples/select-v2/use-valueKey.vue
qiang db0e65577d
refactor(components)!: [select-v2] value-key is used for object select (#13263)
refactor(components): [select-v2] value-key is used for object select
2023-10-13 13:08:34 +08:00

29 lines
594 B
Vue

<template>
<el-select-v2
v-model="value"
:options="options"
placeholder="Please select"
value-key="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({ name: 'Option 1', test: 'test 0' })
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>