上传选取文件(非样式库封装)

<el-button size="small" type="primary" @click="selectFile">选择文件</el-button>
            <input ref="file" type="file" hidden @change="inputChange" />
            <span style="padding-left:15px;">{{fileName}}</span>

public selectFile() {
      this.$refs.file.click();
    }

public inputChange(e: any) {
      this.files = this.$refs.file.files[0];
      if (e.target.value) {
        console.log(this.files);
        this.fileName = this.files.name;
      }
    }

 

posted @ 2021-04-14 09:28  jiaqiq  阅读(44)  评论(0编辑  收藏  举报