Open hytzgroup opened 4 years ago
(function(){
var carManager = {
// request information
requestInfo: function( model, id ){
return "The information for " + model + " with ID " + id + " is foobar";
},
// purchase the car
buyVehicle: function( model, id ){
return "You have successfully purchased Item " + id + ", a " + model;
},
// arrange a viewing
arrangeViewing: function( model, id ){
return "You have successfully booked a viewing of " + model + " ( " + id + " ) ";
},
execute:function ( name ) {
return carManager[name] && carManager[name].apply( carManager, [].slice.call(arguments, 1) );
}
};
})();
1.策略模式 2.MVC 3.angular-ui-router 0.4.3
命令模式 封装方法调用。 命令模式可以用来对方法调用进行参数化处理和传送,经过这样处理过的方法调用可以在任何需要的时候执行。 消除调用操作(action)的对象和实现操作的对象之间的耦合,这为各种具体的类的更换带来了极大的灵活性。 创建用户界面,undo操作 代替回调函数,提高对象之间传递操作的模块化程度。
画图板程序 上传下载
var receiver = new Receive();
var command = new Command(receiver);// receiver.action()
var invoker = new Invoker(command);
invoker.action();// command.excute()
https://www.cnblogs.com/cg88/p/9480143.html