naive-ui
naive-ui copied to clipboard
Select 组件 render-label 和 value-field 同时使用
问题的清晰而简明的描述
const formState = reactive({
orgList: [ {id: '1', name: '111', type: '1'1}, {id: '2' , name: '2' , type: '2'} ]
orgId: ''
});
function renderLabel(option: SelectOption): VNodeChild {
return [
h(
NTag,
{ type: ORG_TYPE_TAG_MAP.get(option.type), class: 'mr-2' },
{ default: () => ORG_TYPE_MAP.get(option.type) }
),
option.name as string
];
}
<NSelect v-model:value="formState.orgId" :options="formState.orgList" value-field='id' :render-label="renderLabel"></NSelect>
上述代码,能正常渲染下拉框, 但在选中后,无法回显。
建议的解决方案
支持 render-label 和 value-field 同时使用
备选方案
No response
附加上下文
No response
验证
提供个复现链接
提供个复现链接
https://github.com/zuihou/soybean-admin/blob/main/src/views/multi-menu/first_child/index.vue
我也遇到了跟你一模一样的问题 这个解决了嘛