Requirejs不加载data-main

时间:2014-04-23 08:41:47

标签: javascript requirejs

你好,我有这样的HTML

<body>
 ...
 <div id="game">
   console
   <div id="message"></div>
   <script data-main="js/console" src="/js/lib/require.js"></script>
 </div>
...
</body>

我的js / console.js没有加载(我在chrome开发工具中看到这个),任何想法? console.js

require.config({
    urlArgs: "_=" + (new Date()).getTime(),
    baseUrl: "js",
    paths: {
        jquery: "/js/lib/jquery",
        underscore: "/js/lib/underscore",
        backbone: "/js/lib/backbone",
        Connector: "/js/lib/Connector",
        FnQuery: "/js/lib/FnQuery",
        "socket.io": "/socket.io/socket.io"
    },
    shim: {
        'backbone': {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        'underscore': {
            exports: '_'
        },
        "socket.io": {
            exports: "io"
        }
    }
});

define([
    'Connector'
], function(
    Connector
){...
});

因为我不明白问题是,我使用teplates插入这个div()并且它不加载js,是否可以使用jquery或smth else加载它?

1 个答案:

答案 0 :(得分:-1)

试试这样:

   <script data-main="./js/console" src="/js/lib/require.js"></script>