1

我正在使用 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, {});

布局 .js 看起来像:

(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)

我该如何解决这个问题?

4

1 回答 1

3

要将 CanJS 与新的 Steal一起使用,您需要使用 CanJS 的次要分支。目前还没有支持新版本 Steal 的标签发布。

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

"canjs": "bitovi/canjs#minor"

其他的建议:

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

2) 错误提示找不到文件。你确定你已经运行了“bower install”来安装 CanJS 吗?您的配置看起来不错。

于 2014-10-15T18:06:29.137 回答