[英]Polymer attached lifecycle on chrome is different than on firefox
我在頁面中有一個組件 。 目前,我正在從組件觸發事件,並從頁面的附加事件添加eventListener。
當使用firefox時,我沒問題, 頁面在組件之前加載,但是在chrome上,我的情況相反, 組件在page之前加載。 這導致我在組件觸發事件之后添加一個eventListener。
我可以在應用程序后強制加載組件嗎?
適用於Firefox,但不適用於chrome:
<link rel="import" href="x-el.html" async>
<dom-module id="x-app">
<template>
<x-el id="el"></x-el>
<div hidden$="[[!detail]]">Event Detail: [[detail]]</div>
</template>
<script>
Polymer({
is: 'x-app',
attached: function(){
this.$.el.addEventListener('foo', () => {
this.set('detail', 'hello')
})
}
});
</script>
</dom-module>
<dom-module id="x-el">
<template>
<div>Hello from <code>x-el</code></div>
</template>
<script>
Polymer({
is: 'x-el',
attached: function() {
this.fire('foo', 'hello');
}
});
</script>
</dom-module>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.