浏览代码

fix: The attribute of option does not work

kailong321200875 2 年之前
父节点
当前提交
d946920e61
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 8 1
      src/components/Form/src/components/useRenderSelect.tsx
  2. 2 1
      src/views/Components/Form/DefaultForm.vue

+ 8 - 1
src/components/Form/src/components/useRenderSelect.tsx

@@ -29,8 +29,15 @@ export const useRenderSelect = (slots: Slots) => {
     // 如果有别名,就取别名
     const labelAlias = item?.componentProps?.optionsAlias?.labelField
     const valueAlias = item?.componentProps?.optionsAlias?.valueField
+
+    const { label, value, ...other } = option
+
     return (
-      <ElOption label={option[labelAlias || 'label']} value={option[valueAlias || 'value']}>
+      <ElOption
+        label={labelAlias ? option[labelAlias] : label}
+        value={valueAlias ? option[valueAlias] : value}
+        {...other}
+      >
         {{
           default: () =>
             // option 插槽名规则,{field}-option

+ 2 - 1
src/views/Components/Form/DefaultForm.vue

@@ -528,7 +528,8 @@ const schema = reactive<FormSchema[]>([
           options: [
             {
               label: 'option1-1',
-              value: '1-1'
+              value: '1-1',
+              disabled: true
             },
             {
               label: 'option1-2',