[vue]vue <router-view />使用

vue <router-view />使用
在APP.vue主组件中,内容上就只有<router-view></router-view>,然后在其他页面也有<router-view></router-view>
可以理解为:

一层路径(/xxx)对应一个router-view

比如url: /a/b/c (假设a、b、c都为正常路径,不会作为参数)

/a对应的就是App.vue中的router-view/a进入a.vue
/a/b对应的就是a.vue中的router-view/a/b进入b.vue

<div id="app">
  <router-view />
</div>

当访问/foo时,router-view就被Foo组件代替了

router.map({
    
    
  '/foo':{
    
    
    component: Foo
  }
})

猜你喜欢

转载自blog.csdn.net/qq_14993591/article/details/121443084