方式一
let color = '#'+Math.floor(Math.random()*256).toString(10);
方式二
let color = '#'+Math.floor(Math.random()*0xffffff).toString(16);
方式三
let r=Math.floor(Math.random()*256);
let g=Math.floor(Math.random()*256);
let b=Math.floor(Math.random()*256);
let color = "rgb("+r+','+g+','+b+")";
网友评论