<!-- 上传--> <input v-show="false" ref="fileRef" type="file" @change="fileChange"> <el-button @click="uploadFile"></el-button> methods: { uploadFile() { this.$refs.fileRef.dispatchEvent(new MouseEvent('click')) }, fileChange() { // 上传文件 } }
<!-- 上传--> <input v-show="false" ref="fileRef" type="file" @change="fileChange"> <el-button @click="uploadFile"></el-button> methods: { uploadFile() { this.$refs.fileRef.dispatchEvent(new MouseEvent('click')) }, fileChange() { // 上传文件 } }