随机数字加字幕id

const Util = window.Util || {};
Util.uniqueId = (length = 16, namespace = "jk") => {
let text = "";
const possible = "abcdefghijklmnopqrstuvwxyz0123456789";

for (let i = 0; i < length; i++) {
text = `${text}${possible.charAt(Math.floor(Math.random() * possible.length))}`;
}
return `${namespace}-${text}`;
};
posted @ 2023-05-22 11:36  膽小  阅读(3)  评论(0编辑  收藏  举报