refactor: 区分同时有两个MsTreeSelect组件的情况

This commit is contained in:
teukkk 2024-11-13 18:18:36 +08:00 committed by Craftsman
parent 1d08e57664
commit b5bd331f67
1 changed files with 2 additions and 4 deletions

View File

@ -15,7 +15,6 @@
:content-style="{ width: `${triggerWidth}px` }"
>
<a-tree-select
:id="treeSelectId"
ref="treeSelectRef"
v-model:model-value="checkedKeys"
v-model:input-value="inputValue"
@ -96,7 +95,7 @@
import { useI18n } from '@/hooks/useI18n';
import useSelect from '@/hooks/useSelect';
import { findNodeByKey, getGenerateId } from '@/utils';
import { findNodeByKey } from '@/utils';
import type { TreeFieldNames, TreeNodeData } from '@arco-design/web-vue';
@ -116,7 +115,6 @@
const { t } = useI18n();
const treeSelectId = ref(getGenerateId()); //
const viewSelectOptionVisible = ref(false);
const selectValue = defineModel<Array<string | number>>('modelValue', { required: true, default: [] });
@ -248,7 +246,7 @@
const triggerWidth = ref<number>(280); //
function updateTriggerWidth() {
const treeSelectInput = document.getElementById(treeSelectId.value) as HTMLElement;
const treeSelectInput = treeSelectRef.value?.$el.nextElementSibling as HTMLElement;
if (treeSelectInput) {
triggerWidth.value = treeSelectInput.offsetWidth; //
}