顯示具有 angular 標籤的文章。 顯示所有文章
顯示具有 angular 標籤的文章。 顯示所有文章

2017-07-16

Ionic3 Lazy Load Page 的問題

今天是 7/16/2017

Ionic 3 的程式愈寫愈多,愈來愈複雜。
本來為了加快程式的載入速度,所以所有 Page 很早就全用 Lazy Load ,直至愈後面,Page 愈寫愈深,因此造成了一些問題要用很怪的手段解決,使用 Ionic 3.5.3 依舊一樣。

本來官方app-script 預設 generate page 是 Lazy Module,現在看到官方 app-script 改成預設為一般 Page, 故勸各位 Ionicer 還是依照官方的方式,用一般 Page。 待官方 ionic g page XXXPage 改為有 XXX.module.ts 的時候再用 Lazy Load Page


目前我發現的問題有:

2017-05-17

通用的@Component/@directive... 共用到各Lazy Page會遇到 error

** 這問題發生在 Angular4.0, 其它版本沒試過 **

如果你有一個 Component 或者 Directive 會在各個 Page 重複使用,你可能會遇到這樣的錯誤訊息

Error: Type ValidateOnBlurDirective is part of the declarations of 2 modules: SignupPageModule  and LoginPageModule! Please consider moving ValidateOnBlurDirective to a higher module that imports SignupPageModule and LoginPageModule. You can also create a new NgModule that exports and includes ValidateOnBlurDirective then import that NgModule in SignupPageModule and LoginPageModule.


意思就是說你有個 component 分別在 LoginPage 及 SignupPage 這2個 LazyPage 共用了。解決方法就是新建一個 NgModule ,將 該 Component 放在該 NgModule 裡,然後再由 LoginPage 及 SignupPage  Import 進去使用即可解決