var MacBikeFactory = {
createBike : function() {
return new MacBike();
}
}
function IMacBike() {}
function MacBike() {}
MacBike.prototype = {
constructor : MacBike,
getBike: function() {
console.log("创建一台Mac车");
}
}
var macFn = MacBikeFactory.createBike();
macFn.getBike();function IMacBikeFactory() {}
function MacBikeFactory() {
this.createBike() {
return new MacBike();
}
}
function IMacBike() {}
function MacBike() {}
MacBike.prototype = {
constructor : MacBike,
getBike: function() {
console.log("创建一台Mac车");
}
}
var macBikeFactory = new MacBikeFactory();
var macBike = IMacBikeFactory.createBike();
macBike.getBike();
【JS设计模式】温习简单工厂模式、工厂方法模式、抽象工厂模式概念
原文:http://www.cnblogs.com/slgkaifa/p/7383734.html