zoukankan      html  css  js  c++  java
  • 前端自己生成id的方法

     // 生成ID
            generateId() {
                const s = [];
                const hexDigits = '0123456789abcdef';
                for (let i = 0; i < 36; i++) {
                    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
                }
                // bits 12-15 of the time_hi_and_version field to 0010
                s[14] = '4';
                // bits 6-7 of the clock_seq_hi_and_reserved to 01
                s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
                s[8] = s[13] = s[18] = s[23] = '-';
                const uuid = s.join('');
                return uuid;
            },
  • 相关阅读:
    C语言指向指针的指针
    C语言注意事项
    C语言指针
    C语言字符串
    C语言数组
    C语言交换两个数的值
    C语言位运算符
    C语言各种进制输出
    C语言中各种进制的表示
    C 语言sizeof运算符
  • 原文地址:https://www.cnblogs.com/dandanyajin/p/15109010.html
Copyright © 2011-2022 走看看