+
80
-

js如何生成随机用户昵称?

js如何生成随机用户昵称?


网友回复

+
0
-
   <script type="text/javascript">
     // 第一个参数为你想生成的固定的文字开头比如: 网友xxxxx
// 第二个为你想生成出固定开头文字外的随机长度
let random = (prefix = "", randomLength = 7) => {
    // 兼容更低版本的默认值写法
    prefix === undefined ? prefix = "" : prefix;
    randomLength === undefined ? randomLength = 8 : randomLength;
 
    // 设置随机用户名
    // 用户名随机词典数组
    let nameArr = [
        [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]...

点击查看剩余70%

我知道答案,我要回答