1.策略模式 1.策略模式在对象中定义方法(相当于switch的情况),通过函数名访问方法。 const strategy = { fun1(arg){...} fun2(arg){...} ...} xxFun(type,arg){ return strategy[type](arg) }