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

// 随机生成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
    },

 

posted @ 2022-10-10 14:33  Private!  阅读(131)  评论(0编辑  收藏  举报