Loading... 使用Math.random()生成随机数 0.5400247964200626 数字的.toString(n) 将数字转换为 n 进制的字符串 n取值范围(0~36)"0.mz6ceycpyfm" 使用 substr 截取去除前面的 0. 使用 toUpperCase() 转换为大写 N1RINBPJNK ``` Math.random().toString(36).substr(2).toUpperCase(); ``` 使用这个方式可以生成随机颜色 #7A0B91 ``` '#' + Math.random().toString(16).substr(2, 6).toUpperCase(); ``` 最后修改:2021 年 07 月 15 日 © 允许规范转载 打赏 赞赏作者 微信 赞 0 如果觉得我的文章对你有用,请随意赞赏
此处评论已关闭