mirror of https://github.com/layui/layui
fix(form): 修复 form.val 第二个参数为 ArrayLike 时表单赋值异常 (#2455)
parent
0cde55a43d
commit
317512bbb1
|
@ -105,9 +105,12 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|||
var itemForm = $(this);
|
||||
|
||||
// 赋值
|
||||
layui.each(object, function(key, value){
|
||||
var itemElem = itemForm.find('[name="'+ key +'"]')
|
||||
,type;
|
||||
for(var key in object){
|
||||
if(!lay.hasOwn(object, key)) continue;
|
||||
|
||||
var type;
|
||||
var value = object[key];
|
||||
var itemElem = itemForm.find('[name="'+ key +'"]');
|
||||
|
||||
// 如果对应的表单不存在,则不执行
|
||||
if(!itemElem[0]) return;
|
||||
|
@ -123,7 +126,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|||
} else { // 其它类型的表单
|
||||
itemElem.val(value);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
form.render(null, filter);
|
||||
|
|
|
@ -770,6 +770,11 @@
|
|||
listener,
|
||||
lay.passiveSupported ? { passive: true, capture: useCapture } : useCapture
|
||||
);
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
lay.hasOwn = function(obj, prop){
|
||||
return hasOwnProperty.call(obj, prop);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue