From 6d43db5e229a00a4a16e76b84db7f8668fbb792d Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Fri, 28 Apr 2023 16:31:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20layui.sort=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=B8=80=E4=B8=AA=E5=8F=82=E6=95=B0=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E7=9B=B4=E6=8E=A5=E4=BF=AE=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/layui.js b/src/layui.js index 03a8dadb..fdb0daaf 100644 --- a/src/layui.js +++ b/src/layui.js @@ -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;