diff --git a/apps/web-antd/src/adapter/component/index.ts b/apps/web-antd/src/adapter/component/index.ts index 7e64c49bbe1..3a4f9e5a14a 100644 --- a/apps/web-antd/src/adapter/component/index.ts +++ b/apps/web-antd/src/adapter/component/index.ts @@ -89,7 +89,7 @@ async function initComponentAdapter() { component: Select, loadingSlot: 'suffixIcon', visibleEvent: 'onDropdownVisibleChange', - modelField: 'value', + modelPropName: 'value', }, slots, ); @@ -103,7 +103,7 @@ async function initComponentAdapter() { component: TreeSelect, fieldNames: { label: 'label', value: 'value', children: 'children' }, loadingSlot: 'suffixIcon', - modelField: 'value', + modelPropName: 'value', optionsPropName: 'treeData', visibleEvent: 'onVisibleChange', }, diff --git a/apps/web-ele/src/adapter/component/index.ts b/apps/web-ele/src/adapter/component/index.ts index 25911946822..54e10df8076 100644 --- a/apps/web-ele/src/adapter/component/index.ts +++ b/apps/web-ele/src/adapter/component/index.ts @@ -93,7 +93,6 @@ async function initComponentAdapter() { props: { label: 'label', children: 'children' }, nodeKey: 'value', loadingSlot: 'loading', - modelField: 'modelValue', optionsPropName: 'data', visibleEvent: 'onVisibleChange', }, diff --git a/apps/web-naive/src/adapter/component/index.ts b/apps/web-naive/src/adapter/component/index.ts index 503829a1ea9..8bc56f2c903 100644 --- a/apps/web-naive/src/adapter/component/index.ts +++ b/apps/web-naive/src/adapter/component/index.ts @@ -75,7 +75,7 @@ async function initComponentAdapter() { ...props, ...attrs, component: NSelect, - modelField: 'value', + modelPropName: 'value', }, slots, ); @@ -90,7 +90,7 @@ async function initComponentAdapter() { nodeKey: 'value', loadingSlot: 'arrow', keyField: 'value', - modelField: 'value', + modelPropName: 'value', optionsPropName: 'options', visibleEvent: 'onVisibleChange', }, diff --git a/packages/effects/common-ui/src/components/api-select/api-select.vue b/packages/effects/common-ui/src/components/api-select/api-select.vue index ef91d3f5e3d..71e1f125e3b 100644 --- a/packages/effects/common-ui/src/components/api-select/api-select.vue +++ b/packages/effects/common-ui/src/components/api-select/api-select.vue @@ -50,7 +50,7 @@ interface Props { /** 触发api请求的事件名 */ visibleEvent?: string; /** 组件的v-model属性名,默认为modelValue。部分组件可能为value */ - modelField?: string; + modelPropName?: string; } defineOptions({ name: 'ApiSelect', inheritAttrs: false }); @@ -69,7 +69,7 @@ const props = withDefaults(defineProps(), { loadingSlot: '', beforeFetch: undefined, afterFetch: undefined, - modelField: 'modelValue', + modelPropName: 'modelValue', api: undefined, options: () => [], }); @@ -96,10 +96,10 @@ const getOptions = computed(() => { return data.map((item) => { const value = get(item, valueField); return { - ...objectOmit(item, [labelField, valueField]), + ...objectOmit(item, [labelField, valueField, childrenField]), label: get(item, labelField), value: numberToString ? `${value}` : value, - ...(item[childrenField] + ...(childrenField && item[childrenField] ? { children: transformData(item[childrenField]) } : {}), }; @@ -113,9 +113,9 @@ const getOptions = computed(() => { const bindProps = computed(() => { return { - [props.modelField]: unref(modelValue), + [props.modelPropName]: unref(modelValue), [props.optionsPropName]: unref(getOptions), - [`onUpdate:${props.modelField}`]: (val: string) => { + [`onUpdate:${props.modelPropName}`]: (val: string) => { modelValue.value = val; }, ...objectOmit(attrs, ['onUpdate:value']), diff --git a/playground/src/adapter/component/index.ts b/playground/src/adapter/component/index.ts index d4a8ffb18d2..3384551b137 100644 --- a/playground/src/adapter/component/index.ts +++ b/playground/src/adapter/component/index.ts @@ -89,7 +89,7 @@ async function initComponentAdapter() { ...attrs, component: Select, loadingSlot: 'suffixIcon', - modelField: 'value', + modelPropName: 'value', visibleEvent: 'onVisibleChange', }, slots, @@ -104,7 +104,7 @@ async function initComponentAdapter() { component: TreeSelect, fieldNames: { label: 'label', value: 'value', children: 'children' }, loadingSlot: 'suffixIcon', - modelField: 'value', + modelPropName: 'value', optionsPropName: 'treeData', visibleEvent: 'onVisibleChange', },