2017-02-27 78 views
1

我正在通過聯繫人管理器教程工作,當我加入路由器時,我的應用程序停止工作。任何提示將不勝感激。加載bootstrap.css似乎是一個問題。這是從Chrome調試窗口輸出:聯繫人管理器教程中的Aurelia應用程序啓動問題

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 

回答

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文件(因此會發生單獨的請求)。

+0

我已經在aurelia.json中引導了引用。我去嘗試設置存根屬性,首先將需求行添加回app.html。在保存ts時,應用程序現在可以正確加載。我確實在教程之後構建了其他應用程序,以便進行更改。我將重現這一點,看看它的工作原理。 – user3004524