javascript/TypeScript 生成GUID

1 export const guid = () => {
2         return `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, function (c) {
3             let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
4             return v.toString(16);
5         }).toUpperCase();
6     }

作品展示:
http://www.88boxs.cn/
http://36nc.cn/
原文地址:https://www.cnblogs.com/menu/p/6726424.html