用代码逻辑来控制下拉框的展开与收起。
xxx.value.handleClose()
xxx.value.handleOpen()
<template>
<el-button @click='handleClose'>关闭下拉框</el-button>
<el-button @click='handleOpen'>打开下拉框</el-button>
<el-dropdown ref="dropdownRef" >
</el-dropdown>
</template>
<script setup>
let dropdownRef = ref(null) //下拉框ref
//关闭下拉框
const handleClose = () => {
dropdownRef.value.handleClose()
}
//打开下拉框
const handleOpen = () => {
dropdownRef.value.handleOpen()
}
</script>