js随机生成ID

processID = () => {
  const uuid = 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
      const r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
      return v.toString(16);
  });
  return uuid;
}
posted @ 2019-12-13 14:11  林中有风  阅读(1001)  评论(0编辑  收藏  举报