Vue 生成包含数字大小写字母的随机字符串

generateRandomID() {
				const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
				const idLength = 30; // 字符串长度 这里生成30位的
				let randomID = '';

				for (let i = 0; i < idLength; i++) {
					const randomIndex = Math.floor(Math.random() * characters.length);
					randomID += characters.charAt(randomIndex);
				}

				return randomID;
			},

控制台打印出来:

你可能感兴趣的:(笔记,vue.js,前端,javascript)