JavaScript获取随机颜色的方法 function getRGB(){ let r = parseInt(Math.random() * 256), //0-255 g = parseInt(Math.random() * 256), //0-255 b = parseInt(Math.random() * 256); //0-255 return `rgb(${r},${g},${b})` //使用了es6的模板字符串 }