before:文件提交上传前的回调,在此回调方法中添加额外参数
例:this.data = { ‘type’: 1 };
var uploadRender = upload.render({
elem: '#upbox'
, url: apiUrl + "/logistics/express/import" //改成你自己的上传接口
, accept: 'file' //普通文件
, before: function (obj) {
this.data = { 'type': 1 };//关键代码
}
, done: function (res, index) {
console.log(res, index)
if (res.errcode != 0) {
layer.msg(res.msg, {
icon: 2
})
} else {
layer.msg('上传成功', {
icon: 1
})
}
}
});