asd/asd-pc/node_modules/uview-ui/libs/function/randomArray.js
愉快的大福 eb8378e551 init
2024-11-21 11:06:22 +08:00

8 lines
228 B
JavaScript

// 打乱数组
function randomArray(array = []) {
// 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0
return array.sort(() => Math.random() - 0.5);
}
export default randomArray