CanJS与StealJS 0.3.0

时间:2014-10-15 17:47:27

标签: canjs stealjs

我在使用canjs 2.1.0和stealjs 0.3.0的应用程序中玩游戏:

我有stealconfig.js,如下所示:

System.config({
    map: {
        "can/util/util": "can/util/jquery/jquery",
        "jquery/jquery": "jquery"
    },
    paths: {
        "jquery": "bower_components/jquery/dist/jquery.js",
        "can/*": "bower_components/canjs/*.js",
        "lodash": "bower_components/lodash/dist/lodash.js",
        "bootstrap" : "bower_components/bootstrap/dist/js/bootstrap.js",
        "bootstrap.css" : "bower_components/bootstrap/dist/css/bootstrap.csscss"
    },
    meta: {
        jquery: {
            exports: "jQuery",
            deps: supportsUnknownElements ? undefined : ["can/lib/html5shiv.js"]
        }
    },
    ext: {
        mustache: "can/view/mustache/system"
    }
});

我的main.js是:

import can from 'can/';
import $ from 'jquery';
import _ from 'lodash';
import LayoutController from 'apps/layout/layout';

can.route.ready();
new LayoutController(document.body, {});

layout .js loos like:

(function() {
  'use strict';
  var can = require('can/'),
      layoutView = require('./view/layout.mustache!');
})();

但是,我收到了这些错误。

GET http://localhost:8080/bower_components/canjs/can.js 404 (Not Found)
GET http://localhost:8080/bower_components/canjs/view/mustache/system.js 404 (Not Found)

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

将CanJS与新窃取you need to be using the minor branch of CanJS一起使用。还没有标签发布,它支持新版本的Steal。

您可以使用bower轻松完成此操作,就像这样(在您的依赖项中):

"canjs": "bitovi/canjs#minor"

其他评论:

1)当您使用CommonJS(就像在layout.js中一样)时,您不需要将其包装在自我调用函数中。这将由Steal完成。

2)错误表明找不到该文件。你确定你已经跑过" bower install"安装CanJS?您的配置看起来很好。