函数生成器UID(长度) { 返回window.btoa( 阵列 字符串 . 从 来自字符代码 ( ... window.crypto.getRandomValues(新Uint8Array(长度*2 ))).map(c=>String.fromCharCode(c )) .join(“” )).replace(/[+/]/g,“”).substring(0,长度); } console.log(生成UID(22));// “yFg3以上v2cE9cKOXd7hHwWp” console.log(生成UID(5));// “YQGzP”