vue3+ts 定義props中的物件陣列

Amnesia_999發表於2024-10-25
<script setup lang="ts">
declare interface infoVo {
  id?: string;
  reason?: string;
}
// declare type infoListVo = infoVo[]
// declare interface infoListVo {
//     [index: number]: infoVo
// }

const props = defineProps({
    infoList: {type: Array as () => infoVo[], default: () => []},
});

/*** 提示資訊 */
let infoList = reactive<infoVo[]>([]);

watch(() => props.infoList, val => {
  infoList = val
})

</script>

相關文章