個人想法
aem的前端的特點給我的感覺就是一個jquery的插件系統(tǒng)祸憋,通過Jq獲取對象后調(diào)用adaptTo方法轉(zhuǎn)成指定的coral或者foundation對象蹂楣,然后這些對象實現(xiàn)了指定的接口,通過這樣規(guī)范化前端組件的行為,這里記一些日常經(jīng)常使用的方法沿盅,不過最有效的還是官方文檔:Granite UI Foundation組件文檔
-
foundation-contentloaded
當組件被插入dom節(jié)點的時候把篓,總是會觸發(fā)這個事件,可以再頂層的document上注冊一個事件監(jiān)聽腰涧,這樣每次觸發(fā)的時候冒泡上來都能觸發(fā)監(jiān)聽回調(diào)
$(document).on("foundation-contentloaded", function(e) {
console.log("hello");
});
foundation-adapter
foundation的核心方法韧掩,擴展DOM對象,達到組件化的目的foundation-collection
這篇文檔非常有用窖铡,一步步闡述了為什么foundation會使用這種架構(gòu)模式疗锐,開頭就點名了主旨:A collection represents a group of items. A concept of collection is one of the most frequently used concept in a UI. For example, a starting point to implement a CRUD pattern is usually done by listing the available items
我的感覺就是:把通用的一些操作抽象成一個由class構(gòu)成的組件,然后adaptTo出一個組件對象费彼,只要class符合滑臊,就可以轉(zhuǎn)換成組件對象,然后使用CURD操作箍铲,就不用每次自己手動指明到具體的class雇卷,懂了這篇文章后,才算是真的能看懂其他的組件文檔了