YUI3模块化定制

demo:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="http://yui.yahooapis.com/3.10.0/build/yui/yui-min.js"></script>
</head>
<body>
    <div id="demo"></div>
    <script type="text/javascript">
    YUI({
        modules:{
            'hello':{                    
                fullpath:'hello.js',
                requires:['node-base']
            }
        }
    }).use('hello',function(Y){
        Y.hello.sayHello(Y.one('#demo'));
    })
    </script>
</script>
</body>
</html>

外部定义的单独js模块:

YUI.add('hello',function(Y){
    function addMessage(node,html){
        node=Y.one(node);
        if(node){
            node.setHTML(html);
        }
    }
    Y.namespace('hello').sayHello=function(node){
        addMessage(node,'hello world');
    }
},'0.0.1',{requires:['node-base']})

Yui提供各类强大的模块化管理工具集,对项目js进行模块化开发提供了便捷

原文地址:https://www.cnblogs.com/wangwenfei/p/YUI3.html