當啓動Aurelia應用程序時,我們已經注意到IE11中真正奇怪的行爲。 只有在您第一次在新窗口/選項卡中啓動應用程序並且鼠標光標不在IE窗口區域(例如,程序從具有給定url的命令行運行 - 這對我們來說這是重要場景)時纔會發生。然後,應用程序停留在帶有靜態內容的index.html中,但沒有任何反應。 直到你將光標移動到窗口上...然後神奇的應用程序繼續沒有任何錯誤和任何問題。IE11承諾奇怪的行爲
只要我能調試,當腳本進入System.import('core-js')諾言時就會發生問題。它發生在或不使用藍鳥許諾。
這是來自「index.html」的正文。
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('core-js').then(function() {
return System.import('webcomponents.js/MutationObserver');
}).then(function() {
return System.import('aurelia-bootstrapper');
});
</script>
編輯:
我注意到,有什麼可以幫助就是把承諾與超時(至少1000毫秒)。如果有更好的解決方案存在,你有什麼想法嗎?
<script src="jspm_packages/npm/[email protected]/js/browser/bluebird.js"></script>
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
// IE11 hack for mutation observer/promises error
var promise = new Promise(function (resolve) {
window.setTimeout(
function() {
resolve();
}, 1000);
});
System.import('core-js').then(function() {
return System.import('webcomponents.js/MutationObserver');
}).then(function() {
return System.import('aurelia-bootstrapper');
});
</script>
聽起來像一個討厭的小錯誤。您可以通過觸發鼠標懸停事件(例如在頁面加載時)強制進行初始化,但請注意不要觸發兩次(安全性可能已經存在,但您需要確保)。 –