MVC 下 合并VC 继承EventBus

68 阅读1分钟

上文链接

controller view 合并

由于v c 里的内容有很多是耦合的,且内容较少,我们将他们合并到一起,放在同一个对象里.

由于app1 和 app2 中也有很多代码重复, 我们将它们提取到类里

View

image.png

Model

image.png

View Model 继承 EventBus

因为View 中有监听 model 中有触发 没有继承的话, 调用会变成eventBus.on("m:updated",fn) 有继承的话 v.on("m:updated",fn) m.trigger("m:updated")