加强 lay.options 方法

pull/1123/head
贤心 2022-08-25 16:52:45 +08:00
parent 8d863d04d8
commit 23f26a9a8d
1 changed files with 8 additions and 5 deletions

View File

@ -202,14 +202,17 @@
} }
}; };
//获取元素上的参数配置上 // 获取元素上的属性配置项
lay.options = function(elem, attr){ lay.options = function(elem, opts){
var othis = lay(elem) opts = typeof opts === 'object' ? opts : {attr: opts};
,attrName = attr || 'lay-options';
var othis = lay(elem);
var attrName = opts.attr || 'lay-options';
try { try {
return new Function('return '+ (othis.attr(attrName) || '{}'))(); return new Function('return '+ (othis.attr(attrName) || '{}'))();
} catch(ev) { } catch(ev) {
hint.error('parseerror'+ ev, 'error'); hint.error(opts.errorText || 'parseerror: '+ ev, 'error');
return {}; return {};
} }
}; };