zoukankan      html  css  js  c++  java
  • vue项目图片上传 vant van-uploader 图片上传

      
    vant    van-uploader 图片上传
     
      <van-uploader accept="image/*" v-model="fileList" multiple :after-read="afterRead"></van-uploader>
     
     
     
       
     afterRead: function(file) {
          if (this.fileList.length > 3) {
            this.$toast.fail("图片上传最多三张!");
            this.fileList.splice(3);
            return;
          }
          let formData = new FormData();
          formData.append("file", file.file);
          this.$api.shopOrdersReturnUpload(formData).then(res => {
            if (!res.success) {
              this.$toast.fail("图片上传失败,请重新上传!");
              return;
            }
            if (res.data) {
              this.$toast.success("图片成功!");
              this.fileList[this.fileList.length - 1].r_path = res.data.r_path;
            }
          });
        },
     
    重点  axios   
    http.interceptors.request.use(
      (config) => {
       config.headers['Content-Type'] = 'multipart/form-data';
      },
      error =>
        Promise.reject(error)
    )
  • 相关阅读:
    Android天线信号刷新流程
    source insight配置
    android light sensor port
    wifi workflow
    vi/vim常用配置及使用命令
    contacts里QuickContactBadge弹出窗口
    ubuntu12.04与windows系统共享
    shell脚本编程
    凤凰照片的大小修改
    wf2
  • 原文地址:https://www.cnblogs.com/FACESCORE/p/12467386.html
Copyright © 2011-2022 走看看