微信公众号前端模版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
796 B

const uuids = []
function getGuid(size) {
if (size) size--;
const uidLen = 13; // 机器码有多少位
const uidText = '1234567890'
let uid = ''; // 定义空变量用来接收机器码
for (let i = 0; i < uidLen; i++) uid += uidText.charAt(Math.floor(Math.random() * uidText.length)); //循环机器码位数随机填充
let uuid = new Date().valueOf() + uid
if (uuids && uuids.find(function (o) { return o === uuid })) {
uuid = !size ? new Date().valueOf() : getGuid(5)
}
uuids.push(uuid)
if (uuids.length > 300) uuids.length = 0
return uuid
}
// for (let index = 0; index < 10; index++) {
// console.log(getGuid(uuids));
// }
const list = ["a", "b", "c"];
let index = list.findIndex((x) => x == "e");
console.log(index); // 1