zoukankan      html  css  js  c++  java
  • Element+Axios上传图片 OR 文件

    Vue template

    <el-upload
        class="avatar-uploader"
        action
        name="file"
        :show-file-list="false"
        :http-request="upLoad" 
        > 
            <div class="upload-btn">上传</div> 
    </el-upload>
    

    Vue Methods

    upLoad(fileObj) {
          uploadImg(fileObj)  // 这里是Axios请求方法
        },  
    

    Axios请求

    import request from '@/utils/request' // 实例化 Axios
    
    export function uploadImg(fileObj,modular="") {
        let formData = new FormData();
        formData.set("file", fileObj.file);
        formData.set("modular", modular);
        return request({
          url: '/common/uploadImage',
          headers: {
            "Content-type": "multipart/form-data"
          },
          method: 'post',
          data: formData
        })
    }
    
  • 相关阅读:
    poj 2000
    poj1316
    poj1922
    poj2017
    poj1833 排列
    poj1338
    poj2136
    poj2242
    IE兼容html5标签
    绑定事件后,某些情况下需要解绑该事件
  • 原文地址:https://www.cnblogs.com/zhonglinke/p/12311998.html
Copyright © 2011-2022 走看看