![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
freya0608
我爱学习。
展开
-
设计模式-工厂模式
class Product { constructor(name){ this.name = name; } init(){ alert('init'); } fun1(){ alert('fun1') } fun2(){ alert('fun2') } } class...原创 2019-06-30 15:11:48 · 88 阅读 · 0 评论 -
设计模式-适配器模式
class Adaptee { specificRequest(){ return '德国标准插头' } } class Target { constructor(){ this.adaptee = new Adaptee() } request(){ let info = this.adaptee.spec...原创 2019-06-30 15:13:32 · 83 阅读 · 0 评论 -
设计模式-观察者模式
// 主题,接收状态变化,触发每个观察者 class Subject { constructor() { this.state = 0 this.observers = [] } getState() { return this.state } setState(state) { this.s...原创 2019-06-30 15:25:21 · 91 阅读 · 0 评论