联络管理器教程中的Aurelia应用程序启动问题

时间:2017-02-27 15:13:36

标签: webpack angular-ui-bootstrap aurelia

我正在通过联系人管理器教程,当我开始添加路由器时,我的应用程序停止工作。任何提示将不胜感激。加载bootstrap.css似乎是一个问题。这是Chrome调试窗口的输出:

DEBUG [aurelia] Loading plugin aurelia-templating-binding. vendor-bundle.js:13902

DEBUG [aurelia] Configured plugin aurelia-templating-binding. vendor-bundle.js:13902 

DEBUG [aurelia] Loading plugin aurelia-templating-resources. vendor-bundle.js:13902

DEBUG [aurelia] Configured plugin aurelia-templating-resources. vendor-bundle.js:13902

DEBUG [aurelia] Loading plugin aurelia-event-aggregator. vendor-bundle.js:13902

DEBUG [aurelia] Configured plugin aurelia-event-aggregator. vendor-bundle.js:13902

DEBUG [aurelia] Loading plugin aurelia-history-browser. vendor-bundle.js:13902

DEBUG [aurelia] Configured plugin aurelia-history-browser. vendor-bundle.js:13902

DEBUG [aurelia] Loading plugin aurelia-templating-router. vendor-bundle.js:13902

DEBUG [aurelia] Configured plugin aurelia-templating-router. vendor-bundle.js:13902

DEBUG [aurelia] Loading plugin resources/index. vendor-bundle.js:13902

DEBUG [aurelia] Configured plugin resources/index. vendor-bundle.js:13902 

DEBUG [aurelia] Loading plugin aurelia-testing. vendor-bundle.js:13902

DEBUG [aurelia] Configured plugin aurelia-testing. vendor-bundle.js:13902 

DEBUG [templating] importing resources for aurelia-templating-resources/compose [] vendor-bundle.js:13902

DEBUG [templating] importing resources for aurelia-templating-router/router-view [] vendor-bundle.js:13912

INFO [aurelia] Aurelia Started vendor-bundle.js:13902

DEBUG [templating] importing resources for app.html ["bootstrap/css/bootstrap.css", "styles.css"] vendor-bundle.js:4834

Uncaught TypeError: plugin.load is not a function

at Module.<anonymous> (vendor-bundle.js:4834)

at vendor-bundle.js:3873

at on (vendor-bundle.js:4256)

at Module.callPlugin (vendor-bundle.js:4694)

at Module.fetch (vendor-bundle.js:4563)

at Module.check (vendor-bundle.js:4595)

at Module.enable (vendor-bundle.js:4915)

at Object.enable (vendor-bundle.js:5296)

at Module.<anonymous> (vendor-bundle.js:4900)

at vendor-bundle.js:3873

at each (vendor-bundle.js:3798)

at Module.enable (vendor-bundle.js:4852)

at Module.init (vendor-bundle.js:4527)

at vendor-bundle.js:5199

1 个答案:

答案 0 :(得分:2)

大多数情况下,您会在以下情况下收到此错误:

  • 您正在尝试加载css文件或其他基于文本的文件(如svg)
  • 此css文件/其他基于文本的文件未包含在捆绑包中
  • stub属性设置为true

您可以执行以下两项操作之一,在包中包含css文件或将stub属性设置为false

我推荐前者,这意味着在aurelia.json中你配置了一个resources属性:

{
  "name": "bootstrap",
  "path": "../node_modules/bootstrap/dist",
  "main": "js/bootstrap.min",
  "deps": ["jquery"],
  "exports": "$",
  "resources": [
    "css/bootstrap.css"
  ]
}

这应该触发CLI捆绑bootstrap.css文件。如果将stub属性设置为false,那么RequireJS将在bundle之外获取bootstrap.css文件(因此会发生单独的请求)。