diff --git a/docs/upload/detail/options.md b/docs/upload/detail/options.md index 00974de7..590c46ae 100644 --- a/docs/upload/detail/options.md +++ b/docs/upload/detail/options.md @@ -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); // 得到文件对象 } } ``` diff --git a/src/modules/upload.js b/src/modules/upload.js index 24cc9e69..1ec113ff 100644 --- a/src/modules/upload.js +++ b/src/modules/upload.js @@ -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); });