mirror of https://github.com/layui/layui
feat(upload): 加强 data 选项的函数写法,支持获取文件相关数据 (#1494)
close https://gitee.com/layui/layui/issues/I8JAC1pull/1504/head
parent
6abb1eedd8
commit
567a1e70c1
|
@ -74,6 +74,11 @@ data: {
|
|||
data: {
|
||||
id: function(){
|
||||
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){
|
||||
value = typeof value === 'function' ? value() : value;
|
||||
value = typeof value === 'function'
|
||||
? sets.unified ? value() : value(sets.index, sets.file)
|
||||
: value;
|
||||
formData.append(key, value);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue