fix(ApiSelect): type warning

This commit is contained in:
Li Kui 2023-10-14 21:05:43 +08:00
parent a0d4b10a1f
commit 8f6153fd2a
1 changed files with 7 additions and 3 deletions

View File

@ -23,6 +23,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, PropType, ref, computed, unref, watch } from 'vue'; import { defineComponent, PropType, ref, computed, unref, watch } from 'vue';
import { Select } from 'ant-design-vue'; import { Select } from 'ant-design-vue';
import type { SelectValue } from 'ant-design-vue/es/select';
import { isFunction } from '/@/utils/is'; import { isFunction } from '/@/utils/is';
import { useRuleFormItem } from '/@/hooks/component/useFormItem'; import { useRuleFormItem } from '/@/hooks/component/useFormItem';
import { useAttrs } from '@vben/hooks'; import { useAttrs } from '@vben/hooks';
@ -41,7 +42,7 @@
}, },
inheritAttrs: false, inheritAttrs: false,
props: { props: {
value: [Array, Object, String, Number], value: { type: Object as PropType<SelectValue> },
numberToString: propTypes.bool, numberToString: propTypes.bool,
api: { api: {
type: Function as PropType<(arg?: any) => Promise<OptionsItem[]>>, type: Function as PropType<(arg?: any) => Promise<OptionsItem[]>>,
@ -55,7 +56,10 @@
valueField: propTypes.string.def('value'), valueField: propTypes.string.def('value'),
immediate: propTypes.bool.def(true), immediate: propTypes.bool.def(true),
alwaysLoad: propTypes.bool.def(false), alwaysLoad: propTypes.bool.def(false),
options: propTypes.array.def([]), options: {
type: Array<OptionsItem>,
default: [],
},
}, },
emits: ['options-change', 'change', 'update:value'], emits: ['options-change', 'change', 'update:value'],
setup(props, { emit }) { setup(props, { emit }) {
@ -63,7 +67,7 @@
const loading = ref(false); const loading = ref(false);
// //
const isFirstLoaded = ref(false); const isFirstLoaded = ref(false);
const emitData = ref<any[]>([]); const emitData = ref<OptionsItem[]>([]);
const attrs = useAttrs(); const attrs = useAttrs();
const { t } = useI18n(); const { t } = useI18n();