<el-upload
class="upload-demo"
action
:limit="1"
:http-request="uploadHttp"
:file-list="fileList">
<el-button size="small" tye="success">点击上传</el-button>
</el-upload>
uploadHttp(param) {
let _this = this;
var data = new FormData();
data.append("file", param.file);
_this.formData = data;
let success = function (resp) {
if (resp.code === "0") {
}
};
_this.http.postFile("", data, success);
},
postFile(url, data, $method) {
return service({
headers: {
'Content-Type': 'multipart/form-data;',
'ref': store.state.ref
},
url: url,
method: 'post',
data: data
}).then(res =>{
$method(res.data);
})
js 文件上传
最新推荐文章于 2024-08-22 14:32:34 发布