父組件
在父組件模板上的子組件上加上屬性值,屬性值就是想要傳遞給子組件的信息。
例如:
<template>
<div class="Big-box"><testBox :personList="p"></testBox>
</div>
</template>
子組件
子組件接收父子間傳遞的信息
const x = defineProps(['personList'])
子組件接收規范的父子間傳遞的信息
const x = defineProps<{personList:Person}>()
子組件接收規范的父子間傳遞的可選的非必要信息
const x = defineProps<{personList?:Person}>()
子組件接收規范的父子間傳遞的可選的非必要信息,有默認值
const x = withDefaults(defineProps<{personList?:Person}>(),{...
})