题目:红灯三秒亮一次,绿灯一秒亮一次,黄灯2秒亮一次;如何让三个灯不断交替重复亮灯?(用Promse实现)
<style>
#l{
width: 100px;
height: 100px;
/* background-color: blueviolet; */
border-radius: 50%;
}
</style>
</head>
<body>
<div id="l"></div>
<script>
function red(){
// console.log("red");
l.style.background="red"
}
function green(){
// console.log("green");
l.style.background="green"
}
function yellow(){
// console.log("yellow");
l.style.background="yellow"
}
var light=function(cb,timer){
return new Promise((resolve,reject)=>{
setTimeout(function(){