美文网首页
生成随机颜色

生成随机颜色

作者: 木利 | 来源:发表于2018-08-15 13:48 被阅读0次
function getRandomColor () {
  const rgb = []
  for (let i = 0 ; i < 3; ++i){
    let color = Math.floor(Math.random() * 256).toString(16)
    color = color.length == 1 ? '0' + color : color
    rgb.push(color)
  }
  return '#' + rgb.join('')
}

相关文章

网友评论

      本文标题:生成随机颜色

      本文链接:https://www.haomeiwen.com/subject/kmfwbftx.html