一个页面里如果想获取图片两个地方用到我们怎模板

我们要给这俩个请求各一个唯一的标识 来判断这个唯一的标识 就相当于index id 或value 等 就可以
inputchange(event,flag) {
let imgArr=''
if(flag===1){
imgArr=this.addimgarr
}else{
imgArr=this.enterpriseImgArr
}
//选择input事件
var self = event.target.files[0];
this.imgType=self.type.split('/')[1]
if (typeof FormData !== "function") {
this.$toast({ text: "浏览器版本过低,请升级浏览器" });
return false;
}
var oMyForm = new FormData();
oMyForm.append("multipartFile", self);
this.$post("/jobtbao-platform-srv/platform/srv/fdfs/upload", oMyForm).then(({ object }) => {
imgArr.push(object.value);
}).catch(this.errFn);
},
delimg(index) {//删除图片事件
if(index===1){
this.addimgarr = [];
}else{
this.enterpriseImgArr = [];
}


},

}, //这个js代码
//第一个请求
<h3>上传营业执照</h3>
<div class="pageimg" v-if="enterpriseImgArr.length===0" prop="photoUrl">
<input type="file" @change="inputchange($event,2)" accept="image/*" />
</div>
//第二个请求
<div class="hardere">
<h3>上传手持身份证照片</h3>
<div class="pageimg" v-if="addimgarr.length===0">
<input type="file" @change="inputchange($event,1)" accept="image/*"/>
</div>

猜你喜欢

转载自www.cnblogs.com/congcong1/p/12935217.html