随机获取一个RGB颜色值
实现代码如下
- 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)
-