vue3.2父子组件传递

1、父传子

父:<HelloWorld :msg=msg_hellow />



子接收:  ts的写法:defineProps<{ msg: string }>()  
		js的写法:cosnt props=defineProps({
					msg:{
						type:String,
						default:()=>"没有传值显示的默认值"
					}
		})

2、子传父

子:
const emit=defineEmits([
    'el-child'
])
//发送
emit('el-child',count.value)

父:
@el-child="TestEmit"
const TestEmit=(v:any)=>{
  console.log("接收到子组件的值",v)
}
posted @ 2022-05-19 14:54  成强  阅读(610)  评论(0编辑  收藏  举报