ElementUI图片在Dialog中上传不回显问题

近日在写项目的时候发现在dialog中上传图片不会回显,上传完还是显示空白。
在这里插入图片描述
后台返回的图片地址也正常,但就是不显示。想了想可能是在dialog中已经弹出显示的对话框不能根据数据刷新节点,于是我就用了this.$forceUpdate()
代码如下:

<el-upload
        action=""
        :show-file-list="false"
        :http-request="uploadImg"
        :before-upload="beforeAvatarUpload">
    <img v-if="acinfo.actImg" :src="acinfo.actImg" class="avatar"/>
    <i v-else class="el-icon-plus avatar-uploader-icon" style="font-size: 30px"></i>
 </el-upload>

//上传方法
uploadImg(param) {
    
    
   upload(param, (imgUrl) => {
    
    
   	if (imgUrl) {
    
    
       this.$forceUpdate()
       this.acinfo.actImg = imgUrl;
    }
   })
},

然后就可以显示图片了
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Macao7_W/article/details/127109477
今日推荐