js设计模式——状态模式 控制灯的开关,关 -> 弱灯 ->强灯 ->关灯循环,这里使用状态模式来设计,省去了大量的if else判断,并且方便宜以后扩展其它状态。直接上代码:// 灯函数const light = function(){ this.ruo = new ruo(this) this.qiang = new qiang(this) this.guan = new guan(this) this.btn = document.createElement('button')...