mirror of https://github.com/layui/layui
新增 laypage 的 `limitTemplet` 属性,用于自定义条目模板
parent
f579596cb2
commit
6f09219ce2
|
@ -156,15 +156,24 @@ layui.define(function(exports){
|
||||||
|
|
||||||
// 每页条数
|
// 每页条数
|
||||||
limit: function(){
|
limit: function(){
|
||||||
var options = ['<span class="layui-laypage-limits"><select lay-ignore>'];
|
var elemArr = ['<span class="layui-laypage-limits"><select lay-ignore>'];
|
||||||
|
var template = function(item) {
|
||||||
|
var def = item +' 条/页';
|
||||||
|
return typeof config.limitTemplet === 'function'
|
||||||
|
? (config.limitTemplet(item) || def)
|
||||||
|
: def;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 条目选项列表
|
||||||
layui.each(config.limits, function(index, item){
|
layui.each(config.limits, function(index, item){
|
||||||
options.push(
|
elemArr.push(
|
||||||
'<option value="'+ item +'"'
|
'<option value="'+ item +'"'+ (item === config.limit ? ' selected' : '') +'>'
|
||||||
+(item === config.limit ? 'selected' : '')
|
+ template(item)
|
||||||
+'>'+ item +' 条/页</option>'
|
+ '</option>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return options.join('') +'</select></span>';
|
|
||||||
|
return elemArr.join('') +'</select></span>';
|
||||||
}(),
|
}(),
|
||||||
|
|
||||||
// 刷新当前页
|
// 刷新当前页
|
||||||
|
|
Loading…
Reference in New Issue