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)
    )
  • 相关阅读:
    java前端学习步骤
    安装Sublime Text 3插件的方法(转自Rising的博文)
    LibSVM学习详细说明
    class 2-3 小项目练习
    class 2-2 小项目练习
    class 2-1 小项目练习
    class 1-1 python开发环境配置
    Class
    class 10 文件和异常
    class
  • 原文地址:https://www.cnblogs.com/FACESCORE/p/12467386.html
Copyright © 2011-2022 走看看