[英]How to use didInsertElement properly in ember.js component?
在組件插入DOM之后,我想注入第三方JS並做一些事情。 所以didInsertElement
掛鈎對我來說很好。
使用didInsertElement
有以下兩種不同的類型。
initialLoad: on('didInsertElement', function() {});
和
didInsertElement() {}
它們之間有什么區別? 我的用例必須使用哪一個? 請指導。
提前致謝 :)
這是要走的路,請參閱Ember組件的生命周期
didInsertElement() {
this._super(...arguments);
}
以下是不正確的方法。 原因是它不遵循任何順序執行功能。 假設如果您有兩個或多個函數已訂閱didInsertElement,則無法確保順序
initialLoad: on('didInsertElement', function() {
});
initialSomeStuff: on('didInsertElement', function() {
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.