vue3如何暴露内容

时间:2025-01-20 15:16:44
子组件中---------------------------------
//暴露内容
const postValue = ref("");
defineExpose({
  postValue, //把子组件的图片暴露出去
});




父组件中-------------------------------
---------------------------------
 <UploadPic ref="postValue" />
// 接收子组件暴露出的图片
const postValue = ref("");




---------------------------------
const addOk = (e) => {
   = false;
  (); //使用父组件暴露的图片
   = ;
};