來聊聊 Component
與 Directive
以及其 input / output 設計模式
Angular style component host 與封裝對照
發表於
什麼是 :host(selector) ?
在 Angular component 中的樣式, 基本上會被 Shadow dom 所隔離, 在 Shadow dom 之中才會是 template 的內容.
樣式中的 host 其實就是指向 Shadow dom, 也就是在父層 template 中所呼叫的 component tag.
一般會將樣式寫在 template 上而不會對 host 進行太多的定義.
那什麼時候會需要將樣式定義在 host 上呢?
Shadow dom 的大小基本上是由其中的 template 所決定, 但是如果要對這個 component 有較精準的定位或相對位置計算等空間排版的需求時, 會需要將 host 定義 display 屬性
遍歷非同步的方式記錄
發表於
一般在使用 loop 的時候會習慣用到 for…of, array forEach …etc, 如果在這些程式碼段裡須搭配非同步(async)的時候會遇到一些問題
例如: 加了 async/await 沒有作用…
Hexo Theme 排行榜
發表於
一開始只是想找個 hexo theme 來當作 Blog 的模板, 在網上看到有人針對 Github 星數的排行.
想說乾脆我也來用一個排行的文章, 剛好當作 blog 的一篇文章, 沒想到做著做著遇到好多沒碰過的東西, 原來給自己找了個苦差事呢.