Browse Source

fix: 修复当设置apiselect的immediate为false时,默认赋值后取值不正确传入默认options方案 (#2862)

pull/2873/head
tawen 3 years ago
committed by GitHub
parent
commit
7bcdb46148
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/components/Form/src/components/ApiSelect.vue

4
src/components/Form/src/components/ApiSelect.vue

@ -55,6 +55,7 @@
valueField: propTypes.string.def('value'),
immediate: propTypes.bool.def(true),
alwaysLoad: propTypes.bool.def(false),
options: propTypes.array.def([]),
},
emits: ['options-change', 'change', 'update:value'],
setup(props, { emit }) {
@ -71,7 +72,7 @@
const getOptions = computed(() => {
const { labelField, valueField, numberToString } = props;
return unref(options).reduce((prev, next: any) => {
let data = unref(options).reduce((prev, next: any) => {
if (next) {
const value = get(next, valueField);
prev.push({
@ -82,6 +83,7 @@
}
return prev;
}, [] as OptionsItem[]);
return data.length > 0 ? data : props.options;
});
watchEffect(() => {

Loading…
Cancel
Save