标签:
第十章:门面模式
function addEvent(el, type, fn) { if (window.addEventListener) { el.addEventListener(type, fn, false); } else if (window.attachEvent) { el.attachEvent(‘on‘ + type, fn); } else { el[‘on‘ + type] = fn; } }
function setStyle(elements, prop, val) { for (var i = 0, len = elements.length-1; I < len; ++i) { document.getElementById(elements[i]).style[prop] = val; } } //使用 setStyle([‘foo‘], ‘position‘, ‘absolute‘); setStyle([‘foo‘], ‘top‘, ‘50px‘); setStyle([‘foo‘], ‘left‘, ‘300px‘);
function interfaceMethod(str1, str2, str3) {
...
}
var clientObject = { string1: ‘foo‘, string2: ‘bar‘, string3: ‘baz‘ };
function clientToInterfaceAdapter(o) {
interfaceMethod(o.string1, o.string2, o.string3);
}
《javascript设计模式》笔记之第十章 和 第十一章:门面模式和适配器模式
标签:
原文地址:http://www.cnblogs.com/oadaM92/p/4376194.html