<template>
  <el-upload
    ref="FileUPloader"
    class="upload-demo"
    :action="none"
    :on-change="handleChange"
    :show-file-list="false"
    :file-list="fileList"
    accept=".pdf"
    :limit="1"
    :auto-upload="false"
    :http-request="upload"
  >
    <el-button size="small" type="primary">点击上传</el-button>
    <!-- <div slot="tip" class="el-upload__tip">只能上传pdf文件</div> -->
  </el-upload>
</template>
<script>
export default {
  data() {
    return {
      index: 0,
    };
  },
  methods: {
    handleChange(file, list) {
      const extension = file.name.split(".").slice(-1) == "pdf";
      if (!extension) {
        this.$message.warning("上传文件只能是pdf格式!");
        return false;
      }
      // 子传父传id
      this.file("click", function (e) {
        this.$emits("fileupload", file);
      });
    },
  },
};
</script>
<style scoped></style>
