antdVue中TreeSelect组件更改弹窗面板宽度/根据内容撑开

532 阅读1分钟

在组件上添加类名: dropdownClassName="department-tree-select-content" 下拉菜单和选择器同宽。默认将设置 min-width,当值小于选择框宽度时会被忽略。false 时会关闭虚拟滚动: dropdownMatchSelectWidth="false"

<a-tree-select
  dropdownClassName="department-tree-select-content"
  v-model:value="record.department"
  :dropdownMatchSelectWidth="false"
  :dropdown-style="{ maxHeight: '400px', width: '500px', overflow: 'auto' }"
  placeholder="请选择公司/门店/部门"
  :tree-data="state.organizationIDOptions"
  :field-names="{
    children: 'children',
    label: 'title',
    value: 'key'
  }"
/>
<style lang="scss">
.department-tree-select-content {
  width: max-content !important;
}
</style>