<html>
<body>
<button id="button">按我</button>
</body>
<script>
var MacroCommand = function(){
return {
commandsList:[],
add:function( command ) {
this.commandsList.push( command );
},
execute: function(){
for( var i=0,command; command = this.commandsList[i++];) {
command.execute();
}
}
};
}
var openAcCommand = {
execute: function(){
console.log('打开空调'');
}
}
</script>
</html>