Angular父子組件間的路由

在創(chuàng)建組件時:

news組件中還有兩個子組件,newsadd組件中還有兩個子組件

在配置路由時,配置子路由關(guān)鍵字:children

const?routes:?Routes?=?[

{path:'home',component:HomeComponent},

{path:'news',component:NewsComponent,

//引入子路由

?children:[

??{path:'newspage',component:NewspageComponent},

????{path:'welcome',component:WelcomeComponent}

?]

},

{path:'newsadd',component:NewsaddComponent,

??children:[

????{path:'newsaddwelcom??',component:NewsaddwelcomComponent},

????{path:'systemset',component:SystemsetComponent}

??]

},

{path:'**',redirectTo:'home'}

? ?注意要想掛在子組件同時發(fā)布子路由:

父組件的html中掛載? ? :

<router-outet></router-outet>

html構(gòu)成:;兩個路由的鏈接,div中是子組件展示內(nèi)容的地方,所以需要將子組件掛載在那。



此筆記均屬于自己學(xué)習(xí)angular的理解,純粹為了記錄自己的想法,方便查閱,如有錯誤的地方請勿見怪,歡迎指出。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容