1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| //导出页面 <template>
<el-upload class="upload-demo" ref="upload" action="http://localhost:8082/api/upload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :multiple="false" :limit="1" :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($event)">上传到服务器</el-button> <div slot="tip" class="el-upload__tip">只能上传execl文件,且不超过500kb</div> </el-upload>
</template>
<script> export default { data() { return { limitNum: 1, fileList: [], } }, methods:{ handleSuccess(e) { console.log('上传成功', e) this.$message(e.message); }, submitUpload(e) {
console.log('我要上传了', e) this.$refs.upload.submit(); },
handleRemove(file, fileList) { console.log(file, fileList); }, handlePreview(file) { console.log(file); }, } } </script>
<style scoped>
</ //导出页面 <template>
<el-upload class="upload-demo" ref="upload" action="http://localhost:8082/api/upload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :multiple="false" :limit="1" :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($event)">上传到服务器</el-button> <div slot="tip" class="el-upload__tip">只能上传execl文件,且不超过500kb</div> </el-upload>
</template>
<script> export default { data() { return { limitNum: 1, fileList: [], } }, methods:{ handleSuccess(e) { console.log('上传成功', e) this.$message(e.message); }, submitUpload(e) {
console.log('我要上传了', e) this.$refs.upload.submit(); },
handleRemove(file, fileList) { console.log(file, fileList); }, handlePreview(file) { console.log(file); }, } } </script>
<style scoped>
</style>
|