簡體   English   中英

如何在ember.js組件中正確使用didInsertElement?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM