使用js生成随机颜色
const generateRandomColor = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`
console.log(generateRandomColor())
更改随机背景颜色
const generateRandomColor = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`;
const body = document.querySelector('body');
setInterval(()=>{
body.style.backgroundColor = generateRandomColor();
},1000)