Treeselect 单选模式下选择框消失的解决方法
如果将 treeselect 设置为单选模式后,选择框消失了,可能是因为没有设置默认选中的值。在单选模式下,需要通过设置 value 属性来指定默认选中的值。
例如,将 treeselect 设置为单选模式,并指定默认选中的值为 '1',可以这样修改:
<template>
<treeselect v-model="selectedValue" :options="options" :multiple="false" :clearable="true"></treeselect>
</template>
<script>
export default {
data() {
return {
selectedValue: '1',
options: [
{ id: '1', label: 'Option 1' },
{ id: '2', label: 'Option 2' },
{ id: '3', label: 'Option 3' }
]
};
}
};
</script>
这样修改后,选择框会显示默认选中的选项,并且在单选模式下只能选择一个选项。
原文地址: https://www.cveoy.top/t/topic/pczx 著作权归作者所有。请勿转载和采集!