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/

 

posted @ 2017-04-18 10:15  鱼肥肥与肥肥鱼  阅读(1685)  评论(0编辑  收藏  举报