Requirejs模块无法加载

时间:2014-12-01 11:55:57

标签: javascript jquery web-services requirejs shim

我正在尝试运行一个简单的Requirejs应用程序:  js/app.js如下:

   requirejs.config({
    "baseUrl": "js/lib",
    "paths": {
        "app": "../app",
        "jquery": "http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min",
        "highstock": "http://code.highcharts.com/stock/highstock"
    },
    shim: {
        "highstock": {
            "exports": "Highstock",
            "deps": ["jquery"]
        }
    }
});

// Load the main app module to start the app
requirejs(["app/main"]);

js/app/main.js如下:

define(["jquery", "highstock"], function($, Highstock) {
    //the jquery.alpha.js and jquery.beta.js plugins have been loaded.
    $(function() {
        console.log("Hello");
    });
});

app.html如下:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>App</title>
    <script data-main="js/app" src="js/lib/require.js"></script>
</head>
<body>

</body>
</html>

当我运行它时,我可以看到jQuery已正确加载,因为它在控制台上打印Hello。当我检查是否已加载Highstock对象时,它表示该对象未定义。我想我正确加载它,所以有人知道可能出错吗?

0 个答案:

没有答案