<template>
    <div class="demo-page">
      <p>测试页面</p>
      <el-upload
        class="certificate-avatar-uploader"
        :action="uploadImgUrl"
        :show-file-list="false"
        accept=""
        :on-success="(res)=>handleAvatarSuccess(res)"
        :headers="headers"
        :before-upload="beforeAvatarUpload">
        <i class="el-icon-plus avatar-uploader-icon" style="width:200px;">普通上传</i>
      </el-upload>
    </div>
</template>

<script>
  import { getToken } from "@/utils/auth";
  export default {
    name: 'demo',
    data() {
      return {
        uploadImgUrl: this.uploadUrl()+'?ifAsy=true', // 上传的图片服务器地址
        headers: {
          Authorization: "Bearer " + getToken(),
        },
      };
    },
    created(){

    },
    mounted(){

    },
    methods: {
      handleAvatarSuccess(res, type) {
        if(res.code == 200){
          console.log('上传成功res-',res);
          this.msgSuccess('上传成功!')
        }else{
          this.msgError(res.msg)
        }
        this.$forceUpdate()
      },
      beforeAvatarUpload(file) {
        console.log('上传类型检测已关闭-',file)
        return true
      },
    }
  }
</script>

<style scoped>

</style>
