<el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
<input type="file" ref="photoFile" accept="image/jpeg,image/jpg,image/png" multiple @change="selectFile($event)"/>
<img ref="preView" style="max-width:80%"/>
....
如题,我想对话框弹出之前,想清空input,img的内容
this.$refs.preView.src ="";
this.$refs.photoFile.value="";
this.$refs里找不到preView,photoFile
这个是啥子原理
这是因为对话框弹出之前没这个这个DOM, 既然都使用Vue了, 为什么还要操作DOM呢 ,完全可以这么写以img举例, :
<img :src="imgSrc" style="max-width:80%"/>
弹出前:
this.imgSrc = ''