zoukankan      html  css  js  c++  java
  • 一个页面里如果想获取图片两个地方用到我们怎模板

    我们要给这俩个请求各一个唯一的标识 来判断这个唯一的标识 就相当于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>

  • 相关阅读:
    leetCode21. 合并两个有序链表
    (flag)每日三道面试题(4.25)
    每日三加一面试题(4.21)
    按照顺序执行异步函数
    javascript Proxy 代理模式深度监听对象、数组变化
    数据结构与算法(二) 线性表一
    This关键字
    数据结构与算法(一)
    Git报错信息
    MakeDown语法学习
  • 原文地址:https://www.cnblogs.com/congcong1/p/12935217.html
Copyright © 2011-2022 走看看