首页 > 技术文章 > javascript/TypeScript 生成GUID

menu 2017-04-18 10:15 原文

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/

 

推荐阅读