vue局部跳轉,實現一個類似選項卡tab功能


1,這是路由部分,父組件和兩個子組件

注意:子路由path路徑要    “/”+“父路徑”+“/”+“子路徑”

 1  {
 2             path:"/father",
 3             name:'father',
 4             component:()=>import("@/demo/father"),
 5             children:[
 6                 {
 7                     path:"/father/son1",
 8                     name:'son1',
 9                     component:()=>import("@/demo/son1"),
10                 },
11                 {
12                     path:"/father/son2",
13                     name:'son2',
14                     component:()=>import("@/demo/son2"),
15                 }
16             ]
17         },

 

2.兩個子路由的界面里隨便給點東西

1 <template>
2     <div>
3         我是son1組件
4     </div>
5 </template>

 

3.父組件里面的寫法

注意:link里的寫法為   :to = "{name:roouter頁面的pathname值}"

 1 <template>
 2     <div>
 3        <p>我是父組件</p>
 4        <!-- 子路由 -->
 5        <router-link :to="{name:'son1'}">son1</router-link>
 6        <router-link :to="{name:'son2'}">son2</router-link>
 7 
 8        <router-view></router-view>
 9     </div>
10 </template>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM