mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 09:50:58 +08:00
54 lines
1.3 KiB
Vue
54 lines
1.3 KiB
Vue
<template>
|
|
<div
|
|
:class="[ns.b('dropdown'), ns.is('multiple', isMultiple), popperClass]"
|
|
:style="{ [isFitInputWidth ? 'width' : 'minWidth']: minWidth }"
|
|
>
|
|
<slot />
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { computed, defineComponent, inject, onMounted, ref } from 'vue'
|
|
import { useResizeObserver } from '@vueuse/core'
|
|
import { useNamespace } from '@element-plus/hooks'
|
|
import { selectKey } from './token'
|
|
|
|
export default defineComponent({
|
|
name: 'ElSelectDropdown',
|
|
|
|
componentName: 'ElSelectDropdown',
|
|
|
|
setup() {
|
|
const select = inject(selectKey)!
|
|
const ns = useNamespace('select')
|
|
|
|
// computed
|
|
const popperClass = computed(() => select.props.popperClass)
|
|
const isMultiple = computed(() => select.props.multiple)
|
|
const isFitInputWidth = computed(() => select.props.fitInputWidth)
|
|
const minWidth = ref('')
|
|
|
|
function updateMinWidth() {
|
|
minWidth.value = `${
|
|
select.selectWrapper?.getBoundingClientRect().width
|
|
}px`
|
|
}
|
|
|
|
onMounted(() => {
|
|
// TODO: updatePopper
|
|
// popper.value.update()
|
|
updateMinWidth()
|
|
useResizeObserver(select.selectWrapper, updateMinWidth)
|
|
})
|
|
|
|
return {
|
|
ns,
|
|
minWidth,
|
|
popperClass,
|
|
isMultiple,
|
|
isFitInputWidth,
|
|
}
|
|
},
|
|
})
|
|
</script>
|