From 75218179fa1b50e9a700f4e1c167c1c4ccd8bdb4 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 25 Nov 2021 20:11:24 +0800
Subject: [PATCH] .
---
uview-ui/libs/function/randomArray.js | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/uview-ui/libs/function/randomArray.js b/uview-ui/libs/function/randomArray.js
new file mode 100644
index 0000000..590a048
--- /dev/null
+++ b/uview-ui/libs/function/randomArray.js
@@ -0,0 +1,7 @@
+// 打乱数组
+function randomArray(array = []) {
+ // 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
+ return array.sort(() => Math.random() - 0.5);
+}
+
+export default randomArray
--
Gitblit v1.9.3