YUI 3错误'B.Lang is Undefined'yui-min.js第7行

azz*_*y81 0 yui yui3

我刚刚开始玩和学习YUI3,但即使我早期的实验都失败了.我做了一个非常简单的第一个脚本,然而页面错误加载在萤火虫中,'B.Lang是未定义'yui-min.js第7行.任何人都有任何想法?

<html>
<head>
    <script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
    <title>Untitled 2</title>
    <style>
        #container{
            width: 200px;
            height: 40px;
            padding: 5px;
            text-align: center;
            border: 1px solid #ccc;
            background-color: #ccc;   
        }
    </style>
    <script>

    YUI.use('node', function(Y){

        Y.one("#container").on('click', function(){
            alert("hello world"); 
        });
    })

    </script>
</head>

<body>

<div id="container">CLICK</div>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

dan*_*jah 5

你需要()YUI后:

YUI().use('node', function(Y){

    Y.one("#container").on('click', function(){
        alert("hello world"); 
    });
});
Run Code Online (Sandbox Code Playgroud)

如果你想控制各个方面,比如设置事件回调,你会在后面放置一个配置对象,例如:

YUI({
    combine: true,
    insertBefore: 'insertScriptsBefore',
    onProgress: function(o) {
        //
    },
    onFailure: function(o) {
        //
    },
    onTimeout: function(o) {
        //
    }
}).use('node', function(Y){

    Y.one("#container").on('click', function(){
        alert("hello world"); 
    });
});
Run Code Online (Sandbox Code Playgroud)