生成随机数

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-03-02 11:51  爱放屁的菜鸟  阅读(318)  评论(0)    收藏  举报