一 <router-view/>
在APP.vue主組件中
<router-view><router-view/>(命名視圖)
<router-view/>(嵌套命名視圖)
你可以 router-view
當做是一個容器,它渲染的組件是你使用 vue-router 指定的。其實就是指向的意思。,比如:
視圖層:
<div id="app"> <router-view></router-view> </div>
路由定義:
router.map({ '/foo': { // 路由匹配到/foo時,會渲染一個Foo組件 component: Foo } })
當你訪問 /foo
時,router-view
就被 Foo
組件替換了。
二: <router-link> 映射路由
三: 編程時的路由跳轉 this.$router.push(location) 有兩種跳轉方式
四: 動態路由