fix: 消除绑定属性的类型错误
parent
9ac774cd0a
commit
3e68d4f7fe
|
@ -2,6 +2,7 @@
|
||||||
import { computed, onMounted, ref, unref, useAttrs, useSlots, watch } from 'vue'
|
import { computed, onMounted, ref, unref, useAttrs, useSlots, watch } from 'vue'
|
||||||
import { Tree } from 'ant-design-vue'
|
import { Tree } from 'ant-design-vue'
|
||||||
import { get } from 'lodash-es'
|
import { get } from 'lodash-es'
|
||||||
|
import type { DataNode } from 'ant-design-vue/es/tree'
|
||||||
import { isArray, isFunction } from '@/utils/is'
|
import { isArray, isFunction } from '@/utils/is'
|
||||||
import { handleTree as handleTreeFn } from '@/utils/tree'
|
import { handleTree as handleTreeFn } from '@/utils/tree'
|
||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
|
@ -21,9 +22,10 @@ const emit = defineEmits(['optionsChange', 'change'])
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
const slots = useSlots()
|
const slots = useSlots()
|
||||||
|
|
||||||
const treeData = ref<Recordable[]>([])
|
const treeData = ref<DataNode[]>([])
|
||||||
const isFirstLoaded = ref<boolean>(false)
|
const isFirstLoaded = ref<boolean>(false)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const getAttrs = computed(() => {
|
const getAttrs = computed(() => {
|
||||||
return {
|
return {
|
||||||
...(props.api ? { treeData: unref(treeData) } : {}),
|
...(props.api ? { treeData: unref(treeData) } : {}),
|
||||||
|
@ -87,7 +89,7 @@ async function fetch() {
|
||||||
if (!isArray(result))
|
if (!isArray(result))
|
||||||
result = get(result, props.resultField)
|
result = get(result, props.resultField)
|
||||||
|
|
||||||
treeData.value = (result as Recordable[]) || []
|
treeData.value = (result as DataNode[]) || []
|
||||||
isFirstLoaded.value = true
|
isFirstLoaded.value = true
|
||||||
emit('optionsChange', treeData.value)
|
emit('optionsChange', treeData.value)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue