mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 03:08:21 +08:00
1163d27f71
* feat(components): add empty values * feat(hooks): update * feat(components): update * feat(components): update * feat: update * feat(components): update * feat(components): update * feat(components): update * feat: update doc * feat: add doc
57 lines
897 B
Vue
57 lines
897 B
Vue
<template>
|
|
<el-select
|
|
v-model="value"
|
|
:empty-values="[null, undefined]"
|
|
:value-on-clear="null"
|
|
clearable
|
|
placeholder="Select"
|
|
style="width: 240px"
|
|
@clear="handleClear"
|
|
>
|
|
<el-option
|
|
v-for="item in options"
|
|
:key="item.value"
|
|
:label="item.label"
|
|
:value="item.value"
|
|
/>
|
|
</el-select>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref } from 'vue'
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
const value = ref('')
|
|
|
|
const options = [
|
|
{
|
|
value: '',
|
|
label: 'All',
|
|
},
|
|
{
|
|
value: 'Option1',
|
|
label: 'Option1',
|
|
},
|
|
{
|
|
value: 'Option2',
|
|
label: 'Option2',
|
|
},
|
|
{
|
|
value: 'Option3',
|
|
label: 'Option3',
|
|
},
|
|
{
|
|
value: 'Option4',
|
|
label: 'Option4',
|
|
},
|
|
{
|
|
value: 'Option5',
|
|
label: 'Option5',
|
|
},
|
|
]
|
|
|
|
const handleClear = () => {
|
|
ElMessage.info(`The clear value is: ${value.value}`)
|
|
}
|
|
</script>
|