子组件中---------------------------------
//暴露内容
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;
};
vue3如何暴露内容
于 2022-06-20 10:26:21 首次发布