几种常见的设计模式
简单工厂模式
工厂模式其实就是将创建对象的过程封装起来。就像工厂一样,我们不需要关心工厂怎么制造东西,我们只需要提供材料,就能得到我们想要的东西。
先写一个简单构造函数。
function Clothes(color, size, gender) {
this.color = color
this.size = size
this.gender = gender
}
const clotheA = new Clothes(color, size, gender)
很好,我们可以
原创
2021-07-10 09:50:10 ·
90 阅读 ·
0 评论