关于vue3中对defineProps的约束

interface THeadItem {
  key: string
  title: string
  tooltip?: boolean
  width?: string
}
// 指定 需要是键值对的形式 并且value是string(也可以是number等)  解决在xxx上面找不到xxx类型参数的索引签名
interface ListDataItem {
  [key: string]: string
}
interface Props {
  activeLabel?: string
  tHead: Array<THeadItem>
  showPagination?: boolean
  height?: number
  listData: Array<ListDataItem>
}
const props = withDefaults(defineProps<Props>(), {
  activeLabel: '',
  tHead: () => [],
  listData: () => [],
  showPagination: false,
  height: 700
})
posted @ 2022-08-01 14:57  Life_countdown  阅读(699)  评论(0)    收藏  举报