首页 > 其他分享 > 随机生成字符串,支持字母、数字、下划线

随机生成字符串,支持字母、数字、下划线

时间:2022-10-10 14:46:02浏览次数:40  
标签:index randomStr 下划线 let 随机 字符串 charStr

// 随机生成64位字符,支持字母、数字、下划线
//this.clientSecretValue 输入框的值
    randomRange() {
      let randomStr = ''
      let charStr =
        'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'
      for (let i = 0; i < 64; i++) {
        let index = Math.round(Math.random() * (charStr.length - 1))
        randomStr += charStr.substring(index, index + 1)
      }
      this.clientSecretValue = randomStr
    },

 

标签:index,randomStr,下划线,let,随机,字符串,charStr
From: https://www.cnblogs.com/Privatexaio/p/16775635.html

相关文章