js生成固定格式的随机字母数字字符串

版权声明:盗版必究 https://blog.csdn.net/qq_36658051/article/details/86689849
const guid = () => {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
    const r = (Math.random() * 16) | 0;
    const v = c === 'x' ? r : (r & 0x3) | 0x8;
    return v.toString(16);
  });
};

猜你喜欢

转载自blog.csdn.net/qq_36658051/article/details/86689849