使用el-upload 上传excel文件
<el-dialog
:visible.sync="uploadDialog"
class="eldialog"
>
<el-form class="eldialogForm">
<el-form-item >
<el-upload
class="upload-demo"
:before-upload="beforeUpload"
:on-exceed="handleExceed"
:limit="1"
:http-request="uploadFile"
ref="upload"
action
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
<em>点击上传</em>
</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="colseFile()">取 消</el-button>
<el-button
type="primary"
@click="postFile()"
:disabled="uploading"
>确定</el-button
>
</div>
</el-dialog>
uploadFile(item) {
this.file = item.file;
},
postFile(){
var fileData = new FormData();
fileData.append("file", this.file);
fileData.append("fileType", "0");
axios.post({
data: fileData
}).then(result=>{
})
}
控制台看到的是这样,求问怎么上传参数会显示为
file:binary,
fileType:0
axios.post( fileData).then(result=>{
})
控制台可以看到参数
axios.post(fileData)