vue 使用elementui上传文件到后台
<el-upload class="upload-demo" ref="upload" action="http://192.168.1.4:8082/fanliorder/dealEleOrder/" :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>
data
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); },
vue 使用elementui上传文件到后台
[db:回答]