下拉框使用@click没有作用,要使用@click.native
<input ref="upload-input" accept="*/*" type="file" style="display:none" @change="handleClick">
<input id="uploadFolder" multiple="" ref="uploads-input" style="display:none" @change="handleClicks" accept="*/*" type="file" name="uploadFolder" webkitdirectory>
<el-dropdown>
<el-button class="primaryButton" @click="handleUpload"><i class="fa fa-upload"></i> 上传</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="handleUpload">上传文件</el-dropdown-item>
<el-dropdown-item @click.native="handleUploads">上传文件夹</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
js:
// 上传文件夹的按钮
handleUploads() {
this.$refs['uploads-input'].click()
},
// 上传文件的按钮
handleUpload() {
this.$refs['upload-input'].click()
},
参考:https://blog.csdn.net/marko_zheng/article/details/82454964