使用Firefox,需要webcomponents-lite.min.js
。Webcomponents-lite.min.js加載不正常
在我的index.html我有webcomponents-lite.min.js
執行和負載我routing.js
腳本之前:
<script>
// Setup Polymer options
window.Polymer = {
dom: 'shadow',
lazyRegister: true,
};
// Load webcomponentsjs polyfill if browser does not support native
// Web Components
(function() {
'use strict';
var onload = function() {
// For native Imports, manually fire WebComponentsReady so user code
// can use the same code path for native and polyfill'd imports.
if (!window.HTMLImports) {
document.dispatchEvent(
new CustomEvent('WebComponentsReady', {bubbles: true})
);
}
};
var webComponentsSupported = (
'registerElement' in document
&& 'import' in document.createElement('link')
&& 'content' in document.createElement('template')
);
if (!webComponentsSupported) {
var script = document.createElement('script');
script.async = false;
script.src = '/bower_components/webcomponentsjs/webcomponents-lite.min.js';
script.onload = onload;
document.head.appendChild(script);
} else {
onload();
}
})();
</script>
<link rel="import" href="/elements/elements.html">
<link rel="import" href="/elements/my-app.html">
<style>
body {
margin: 0;
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
line-height: 1.5;
min-height: 100vh;
background-color: #fafafa;
}
</style>
</head>
<body>
<!-- build:remove -->
<span id="browser-sync-binding"></span>
<!-- endbuild -->
<iron-meta key="HOST" value="http://80.40.3.2"></iron-meta>
<my-app></my-app>
<!-- Built with love using Polymer Starter Kit -->
</body>
<script src="/js/routing.js"></script>
然而,看着routing.js
負載webcomponents-lite.min.js
之前就在Firefox中的網絡選項卡。這是導致錯誤,因爲我需要webcomponents-lite.min.js
加載之前routing.js
。
由於沒有aysnc
行爲,應該保證順序,對不對?爲什麼會發生這種情況,我怎樣才能使這個訂單工作,而不需要用更多的事件監聽器進行重寫,以及如果這樣的話呢?