Vue axios 上传图片

 

上传图片接口

// 上传图片
export const uploadBanner = formData => {
  return axios.request({
    url: 'manage/slideshow/save',
    headers: {'Content-Type':'multipart/form-data'},
    data: formData,
    method: 'post'
  })
}

接口调用

let formData = new FormData();
                    formData.append('image',this.selectFile);
                    formData.append('level',this.imgIndexUpload);
                uploadBanner(formData).then(res => {
                    console.log(res.data);
                    if(res.data.code == 200){
                        this.$Message.success(res.data.message);
                    } else {
                        this.$Message.success(res.data.message);
                    }
                }).catch(err => {
                    console.log(err)
                })

 

posted @ 2018-11-21 16:29  LaLaLa_heng  阅读(277)  评论(0编辑  收藏  举报