mirror of
https://gitee.com/layui/layui.git
synced 2025-04-05 17:38:02 +08:00
feat(upload): 加强 data 选项的函数写法,支持获取文件相关数据 (#1494)
close https://gitee.com/layui/layui/issues/I8JAC1
This commit is contained in:
parent
6abb1eedd8
commit
567a1e70c1
@ -74,6 +74,11 @@ data: {
|
|||||||
data: {
|
data: {
|
||||||
id: function(){
|
id: function(){
|
||||||
return $('#id').val();
|
return $('#id').val();
|
||||||
|
},
|
||||||
|
id2: function(index, file){ // 参数支持。2.9.3+
|
||||||
|
// 注:当 unified:true 和 ie8/9 下,参数无效
|
||||||
|
console.log(index); // 得到文件索引
|
||||||
|
console.log(file); // 得到文件对象
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -279,7 +279,9 @@ layui.define(['lay', 'layer'], function(exports){
|
|||||||
|
|
||||||
// 追加额外的参数
|
// 追加额外的参数
|
||||||
layui.each(options.data, function(key, value){
|
layui.each(options.data, function(key, value){
|
||||||
value = typeof value === 'function' ? value() : value;
|
value = typeof value === 'function'
|
||||||
|
? sets.unified ? value() : value(sets.index, sets.file)
|
||||||
|
: value;
|
||||||
formData.append(key, value);
|
formData.append(key, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user