我今天在IE Edge中嘗試了我的Aurelia應用程序,花了20秒來加載首頁。切換頁面也需要不合理的時間,所以我谷歌aurelia邊緣性能,發現添加藍鳥JS庫有助於所有瀏覽器的性能。我找不到的示例,如何添加此庫,除了在system.js
之前添加它的指令。向Aurelia應用程序添加藍鳥應用程序引入錯誤
所以現在不是這樣的:
<script src="/jspm_packages/system.js"></script>
<script src="/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
我有這樣的:
<script src="//cdn.jsdelivr.net/bluebird/3.4.1/bluebird.min.js"></script>
<script src="/jspm_packages/system.js"></script>
<script src="/config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
整個應用程序的工作原理就像它曾經,我已經基本上想盡單一視圖和它的功能,除了之一東西;
在每個路線成功上,我將一個id添加到與當前查看路線匹配的<html>
元素(用於樣式目的)。所以在主頁上我會有<html id="home-page">
和登錄頁面<html id="login-page">
。
這在app.js
(根元素)在其attached()
方法進行,像這樣:
this.eventAggregator.subscribe('router:navigation:success', event => {
if (event.instruction && event.instruction.router && event.instruction.router.currentInstruction && event.instruction.router.currentInstruction.config) {
document.documentElement.id = event.instruction.router.currentInstruction.config.name + '-page';
}
});
出於某種原因,在第一頁的負載,並且僅在第一頁加載,這個事件從未火災。去另一條路線工作正常,並返回到事件從未第一次解僱的路線正常工作。只有在第一頁加載它不會觸發。
如果我刪除藍鳥,它會重新開始工作。
有沒有人有任何想法可能是什麼原因造成這種情況?就像我說的,我所做的唯一改變是將藍鳥script
元素添加到index.html
。在實際的應用程序代碼中我沒有做任何改變。