随机生成16位颜色

createRandomColor() {
  let color = Math.floor((Math.random() * 256 * 256 * 256)).toString(16)
  while (color.length < 6) {//随机生成的可能只有3-6位字符串
  color += Math.floor((Math.random() * 16)).toString(16)
  }
  return color
}

 

posted @ 2017-11-29 11:50  善未易明  阅读(373)  评论(0编辑  收藏  举报