Update index.vue

复用此组件时因为id不可重复的问题会导致onSuccess指向错误。
This commit is contained in:
zhaoguoweiLLHC
2018-09-27 12:50:13 +08:00
committed by GitHub
parent b2c9eb4f7b
commit 1e65175152

View File

@@ -1,6 +1,6 @@
<template>
<div>
<input class="excel-upload-input" ref="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick">
<input ref="excel-upload-input" class="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick">
<div class="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover">
Drop excel file here or
<el-button :loading="loading" style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">Browse</el-button>
@@ -56,7 +56,6 @@ export default {
e.dataTransfer.dropEffect = 'copy'
},
handleUpload() {
// document.getElementById('excel-upload-input').click()
// 改成这样的原因是避免复用改组件时调用onSuccess时的指向错误。
// 因为之前代码为id取值复用组件时会导致id重复错误。所以去掉id取值改为refs样式用class解决。
this.$refs['excel-upload-input'].click();