function uuid() {
var str = "0123456789abcdefghijklmnopqrstuvwxyz";
var i = 0;
var uuidStr = [];
while (uuidStr.length < 32) {
var number = Math.random() * 36;
number = parseInt(number);
uuidStr.push(str[number]);
};
uuidStr[14] = "4";
return uuidStr.join("");
};
function uuid() {
var str = "0123456789abcdef";
var i = 0;
var uuidStr = [];
while (uuidStr.length < 32) {
var number = Math.random() * 16;
number = parseInt(number);
uuidStr.push(str[number]);
};
uuidStr[14] = "4";
return uuidStr.join("");
};
let nanoid = (e = 21) => {
let t = "",
r = crypto.getRandomValues(new Uint8Array(e)); for (let n = 0; n < e; n++)t += "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63 & r[n]];
return t
};
js生成随机id的两个小方法
于 2024-07-12 14:55:32 首次发布