Created
January 13, 2014 10:07
-
-
Save xuanfeng/8397581 to your computer and use it in GitHub Desktop.
JS 模块化写法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 匿名函数-实现模块化 | |
(function(){ | |
// 定义对象 | |
var Draw = {}; | |
// 共有方法 | |
Draw.init = function(){}; | |
// 私有方法 | |
Draw._private = function(){}; | |
// 外部接口 | |
window.Draw = Draw; | |
})(); | |
// 调用模块 | |
(function(win, draw){ | |
window.Draw.init(); | |
})(window, Draw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
还可以试试继承的方式