vue3如何暴露内容
vue3如何暴露内容
·
子组件中---------------------------------
//暴露内容
const postValue = ref("");
defineExpose({
postValue, //把子组件的图片暴露出去
});
父组件中-------------------------------
---------------------------------
<UploadPic ref="postValue" />
// 接收子组件暴露出的图片
const postValue = ref("");
---------------------------------
const addOk = (e) => {
addVisible.value = false;
console.log(postValue.value.postValue); //使用父组件暴露的图片
formState.pic = postValue.value.postValue;
};
更多推荐
已为社区贡献4条内容
所有评论(0)