• element ui图片上传方法


              <!--商品图片-->
              <template v-slot:product_cover>
                <el-upload
                  list-type="picture-card"
                  name="cover"
                  accept="image/png, image/jpeg,image/jpg"
                  :multiple="multiple"
                  :action="cover_upload_action"
                  :headers="upload_header"
                  :on-success="cover_upload_success"
                  :on-progress="cover_on_process"
                  :file-list="cover"
                  :on-preview="handlePictureCardPreview"
                  :on-remove="handleRemove"
                  :limit="6"
                  :on-exceed='on_exceed'>
                  <i class="el-icon-plus">添加主图</i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible">
                  <img width="100%" :src="dialogImageUrl" alt="">
                </el-dialog>
    
              </template>
    

      

     cover_upload_success(resp, file, fileList){
          console.log(fileList)
          let is_last = true;
          fileList.forEach(function(val, index){
           if(typeof val.response == "undefined" && !val.hasOwnProperty('img_id')){
             is_last = false;
           }
          })
          if(is_last){
            fileList.forEach(function(val){
              if(typeof val.response != "undefined")
              {
                store.commit('product/PUSH_COVER',val.response.data);
              }
            })
          }
        },
    

      

  • 相关阅读:
    js判断各个浏览器
    js中的全局函数
    js正则表达式大全(转)
    js url编码函数
    原生的ajax(json)
    原生js拖拽
    js浏览器兼容
    何为反向代理、正向代理
    dom元素循环绑定事件的技巧
    media 适屏
  • 原文地址:https://www.cnblogs.com/guiyishanren/p/13778719.html
Copyright © 2020-2023  润新知