实现代码如下
function randomColor() {
let r = Math.floor(Math.random() * 255);
let g = Math.floor(Math.random() * 255);
let b = Math.floor(Math.random() * 255);
return `rgb(${r},${g},${b})`;
}
console.log(randomColor());
// rgb(178,134,78)
标签:floor,random,rgb,js,RGB,let,随机,Math,255
From: https://blog.51cto.com/mouday/7226448