<!DOCTYPE html>
randomColor #square{ background-color: red; margin: auto; height: 200px; width: 200px; }
<!DOCTYPE html>
var n =0; //写在外面
function setColor(){
var m = n;
while (m == n) m = Math.floor(Math.random()*6);
n = m;
document.getElementById('square').style.backgroundColor = colors[m];
document.getElementById('para').innerHTML = colors[m];
}
}