當我嘗試加載Aurelia模塊時,我正遇到一個奇怪的問題。我已經成功加載moment
庫來格式化日期,但是我試圖加載numeral
庫與npm install <module> --save
完全相同,但它試圖在/dist
目錄中找到numeral
庫,而不是模塊庫。模塊未加載Aurelia
我有空兩個ValueConverters:
使用Moment
代碼:
的src /過濾/時間format.js
import moment from 'moment';
export class TimeFormatValueConverter {
toView(value) {
return moment(value).format('h:mm');
}
}
的src/clock.html
<template>
<require from="./filters/date-format"></require>
<require from="./filters/time-format"></require>
<section class="au-animate">
<h2 class="clock-font-large">${time | timeFormat}</h2>
</section>
</template>
代碼試圖利用Numeral
:
的src /過濾器/溫度format.js
import numeral from 'numeral';
export class TemperatureFormatValueConverter {
toView(value) {
return numeral(value).format('(00)');
}
}
的src/weather.html
<template>
<require from="./filters/temperature-format"></require>
<section class="au-animate">
<h2 class="clock-font-large">${weather.main.temp | temperatureFormat }</h2>
</section>
</template>
我越來越想看看使用numeral
頁面時出現以下錯誤:
ERROR [app-router] Error: (SystemJS) XHR error (404 Not Found) loading http://clock.localhost:9000/dist/numeral.js
Error: XHR error (404 Not Found) loading http://clock.localhost:9000/dist/numeral.js
Error loading http://clock.localhost:9000/dist/numeral.js as "numeral" from http://clock.localhost:9000/dist/filters/temperature-format.js
爲什麼試圖在/dist
目錄,而不是模塊庫看?我知道依賴注入有一些中斷,但我不知道該怎麼做。
鑑於提及'/ dist',@ cchapman不太可能使用Aurelia CLI。 –
好的。謝謝!我的答案只適用於CLI。 – LStarky