Browse Source

fix(ApiSelect): 首次 onChange 无法获取到第二个参数

main
刘凯 1 year ago
parent
commit
f4d602ae61
  1. 1
      src/components/Form/src/components/ApiSelect.vue
  2. 1
      src/components/Form/src/helper.ts
  3. 6
      src/hooks/component/useFormItem.ts

1
src/components/Form/src/components/ApiSelect.vue

@ -126,6 +126,7 @@ function emitChange() {
} }
function handleChange(_, ...args) { function handleChange(_, ...args) {
emit('change', args[0] ? args[0].value : undefined)
emitData.value = args emitData.value = args
} }
</script> </script>

1
src/components/Form/src/helper.ts

@ -85,5 +85,4 @@ export const NO_AUTO_LINK_COMPONENTS: ComponentType[] = [
'AutoComplete', 'AutoComplete',
'RadioButtonGroup', 'RadioButtonGroup',
'ImageUpload', 'ImageUpload',
'ApiSelect',
] ]

6
src/hooks/component/useFormItem.ts

@ -1,5 +1,5 @@
import type { DeepReadonly, Ref, UnwrapRef, WritableComputedRef } from 'vue' import type { DeepReadonly, Ref, UnwrapRef, WritableComputedRef } from 'vue'
import { computed, getCurrentInstance, reactive, readonly, toRaw, unref, watchEffect } from 'vue' import { computed, getCurrentInstance, nextTick, reactive, readonly, toRaw, unref, watchEffect } from 'vue'
import { isEqual } from 'lodash-es' import { isEqual } from 'lodash-es'
@ -37,7 +37,9 @@ export function useRuleFormItem<T extends Recordable>(props: T, key: keyof T = '
return return
innerState.value = value as T[keyof T] innerState.value = value as T[keyof T]
emit?.(changeEvent, value, ...(toRaw(unref(emitData)) || [])) nextTick(() => {
emit?.(changeEvent, value, ...(toRaw(unref(emitData)) || []))
})
}, },
}) })

Loading…
Cancel
Save