父组件:
<template>
<Child :info="value" />
</template>
<script setup lang="ts">
import Child from "@/components/Child.vue"
const value = '我是父组件中的值'
</script>
子组件:
<template>
<p>父组件中的值为:{{info}}</p>
</template>
<script setup lang="ts">
import { toRefs,defineProps} from 'vue'
const props = defineProps({
info: String,
})
const {info} =toRefs(props)
</script>
接收父组件的值后需要对值进行数据类型限制