How does element-ui click the button to trigger upload?

if a few words are added to the official default upload component, how can the upload function be realized when the word is clicked?

clipboard.png


wouldn't it be nice to implement it through css? Cover the clickable area of the element upload component to click upload. To click "Click upload" is to click on the upload component


provides a little idea that el-upload plus a class, triggers the click event manually.

document.querySelector('.class button').click();

there is a manual upload in element

<el-upload
  class="upload-demo"
  ref="upload"
  action="https://jsonplaceholder.typicode.com/posts/"
  :on-preview="handlePreview"
  :on-remove="handleRemove"
  :file-list="fileList"
  :auto-upload="false">
  <el-button slot="trigger" size="small" type="primary"></el-button>
  <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload"></el-button>
  <div slot="tip" class="el-upload__tip">jpg/png500kb</div>
</el-upload>
<script>
  export default {
    data() {
      return {
        fileList: [{name: 'food.jpeg', url: 'https://img.codeshelper.com/upload/img/2021/04/02/vnch0wj1bts14879.jpg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://img.codeshelper.com/upload/img/2021/04/02/vnch0wj1bts14879.jpg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}]
      };
    },
    methods: {
      submitUpload() {
        this.$refs.upload.submit();
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      }
    }
  }
</script>

api

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdcf3f-458cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdcf3f-458cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?