Vue#15 - nested router

1579 단어 vuevue

1. children : router 안에 router만들기

children안에 { } 만들기
"/detail/:id/author" "/detail/:id/comment"로 접속

{
        path : "/detail/:id",
        component : Detail,
        children : [
            {
                path : "author",	// '/' 필요 X
                component : Author.vue,
            },
            {
                path : "comment",
                component : Comment.vue,
            },           
        ]
    },

그리고 어디서 보여줄 지 보여줄 곳에

 <router-view></router-view>
``` 표시

2. router 함수

> 1. push()

@click="$router.push('/')" - 클릭 시 원하는 url로 이동

> 2. go()

@click="$router.go(-1)" - 웹브라우저의 히스토리에서 뒤로 한칸
@click="$router.go(2)" - 앞으로 두칸

3. named view - 여러개의 컴포넌트를 보여줄 때

path : "/list", 
component : {
     List : List,s
     Comment : Comment,
 }, 

4. redirection - 다른 페이지로 강제 이동

 {
        path : "/list",
        redirection : { name : 'homepage' }
 }

❗ $route는 현재경로, $router는 페이지 이동 관련 ❗

좋은 웹페이지 즐겨찾기