//父组件
<template>
//引入的组件展示(childNum:子组件接受的,num:父组件传递)
<childElement :childNum="num" :childList = "parentList"></childElement>
</template>
<script setup>
import { ref, reactive} from "vue";
import childElement from ‘./childElement.vue’(这里的路径写一下自己子组件的路径)
const num = ref(0)
const parentList = reactive(
[ { id:'1', name:'小罗' },
{ id:'2', name:'大罗' }
])
</script>
//子组件 (需要用defineProps接受一下)
<template>
<div>{{childNum}}</div>
<div v-for="(item , index) in childList" :key="index">{{item.name}}</div>
</template>
<script setup>
import { defineProps } from "vue"
defineProps["childNum","childList"]
</script>