web组件
慕课网:http://www.imooc.com/learn/99
js 在实战中的分层:
应用层
框架组件-框架通用组件、定制组件、独立组件
框架core(框架核心层)
浏览器底层
自定义事件:
典型的观察者模式:
on:function(type,handler){ // console.log(type,handler); if(typeof this.handlers[type] == "undefined"){ this.handlers[type] = []; } this.handlers[type].push(handler); return this; }, fire : function(type,data){ console.log(type,data); if(this.handlers[type] instanceof Array){ var handlers = this.handlers[type]; for(var i = 0 , len = handlers.length ; i<len;i++){ handlers[i](data); } } }
widget抽象类 ui相关的封装