创建用户防止用户编码重复,生成一段随机数

// function

createCode () {

const str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

let text = '';

for (let i = 0; i < 20; i++) {

const number = Math.floor(Math.random() * str.length);

const t = str.charAt(number);

text += t;

}

return text;

}

  

posted @ 2020-07-29 10:39  soon_k  阅读(178)  评论(0编辑  收藏  举报