<template>
  <div>
    <el-upload action='' :on-change="getFile" :limit="1" list-type="picture" :auto-upload="false">
</el-upload>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 上传图片列表
      uploadImgList:[]
    }
  },
  methods:{
    getBase64(file) {
      return new Promise((resolve,reject) {
        let reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function() {
          // 读取成功时 将Base64结果返回
          resolve(reader.result);
        };
        reader.onerror = function(error) {
          // 读取错误 返回错误信息
          reject(error);
        };
     });
   },
   getFile(file,fileList) {
     this.getBase64(file.raw).then(res => {
       this.uploadImgList.push(res)
       console.log(this.uploadImgList);
     });
   }
  }
}
</script>