1.问题
使用了Element-ui的el-avatar和el-img标签, 当src绑定一个变量, 变量改变时图片并不会刷新
<el-upload
class="upload-demo"
:action=" BASE_API+'/oss/uploadImg' "
:limit="1"
:auto-upload="true"
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-success="handleSuccess">
<el-avatar style="width: 100px; height: 100px;"
:src="teacher.avatar">
</el-avatar>
</el-upload>
2.解决办法
使用this.$forceUpdate()强制刷新, 这里我把它放在了图片上传成功的回调方法里执行
handleSuccess(response, file, fileList){
this.teacher.avatar=response.data.url
this.$forceUpdate()
},