- 代码环境 :vue3、ts
// 父组件
<component :is="currentTabComponent" :useId="12333"></component>
// 子组件 currentTabComponent
<template>
<div class="left-tree">
哈哈哈哈
</div>
</template>
<script lang="ts" setup>
import {ref, reactive, computed,onMounted,watch } from 'vue'
// 定义接受参数,和普通的父子传参接受方法一样
const props = defineProps({
useId: {
type: String,
default: ''
}
})
onMounted(() => {
// 使用参数
console.log('csndhu',props.useId)
})
</script>