mirror of
https://gitee.com/layui/layui.git
synced 2025-10-27 03:09:32 +08:00
优化 layui.sort 新增一个参数控制是否直接修改数组顺序
This commit is contained in:
@@ -614,12 +614,12 @@
|
||||
};
|
||||
|
||||
// 将数组中的成员对象按照某个 key 的 value 值进行排序
|
||||
Layui.prototype.sort = function(arr, key, desc){
|
||||
Layui.prototype.sort = function(arr, key, desc, notClone){
|
||||
var that = this
|
||||
,clone = JSON.parse(
|
||||
,clone = notClone ? (arr || []) : JSON.parse(
|
||||
JSON.stringify(arr || [])
|
||||
);
|
||||
|
||||
|
||||
// 若未传入 key,则直接返回原对象
|
||||
if(that.type(arr) === 'object' && !key){
|
||||
return clone;
|
||||
|
||||
Reference in New Issue
Block a user