vue element 上传图片 文件

 handleAlbumSuccess1(file){
  //判断文件类型 
const typeList = ["pdf", "xls","xlsx"];
const errMsg = '请上传excel文件'
var tag=this.beforeUpload(file,typeList,errMsg)
  if(tag){
  console.log(file)
  this.file=file
  let formdata=new FormData()
  formdata.append("file",file)
  axios.post("http://115.28.211.100:8002/uploadImage",formdata,{
     headers: {
       'Content-Type': 'multipart/form-data'
       }
       }).then(res=>{
    console.log(res.data)
    this.tableData.productEdition=res.data
    this.fileList1.push({
      name:res.data.substring(res.data.lastIndexOf('/')+1),
      path:res.data
    })
  })}
  },
   //删除图片   
  handleRemove1(file, fileList) {
    this.fileList1.splice(this.fileList1.findIndex(item => item === file), 1)
    console.log(file, fileList);
  },
  beforeRemove1(file, fileList) {
    return this.$confirm(`确定移除 ${ file.name }?`);
  },
  // 检查 文件类型
  beforeUpload(file,arr = [],mssage){
  const typeList = [...arr];
  const fileName = file.name;
  const extension = fileName.substr(fileName.lastIndexOf(".") + 1);
  const isRT = typeList.includes(extension);
    if (!isRT) {
          this.$message.error('请上传正确的文件类型');
    }
    return isRT;
}
```*
原文地址:https://www.cnblogs.com/wp980327/p/14429922.html