我对 Vue.js 2 中的默认子路由有疑问。
当我最初访问 localhost/listings 时,它会正确加载 index.vue 和 map.vue 作为孩子。
当我使用 router-link 导航到 localhost/listings/1,然后使用 router-link 返回 localhost/listings 时,它仍然会加载 show.vue 模板。这不应该发生吗?
我没有导航守卫或任何应该干扰的东西。无论如何要纠正这个问题吗?
我的路线:
window.router = new VueRouter({
routes: [
...
{
path: '/listings',
name: 'listing.index',
component: require('./components/listing/index.vue'),
children: [
{
path: '',
component: require('./components/listing/map.vue')
},
{
path: ':id',
name: 'listing.show',
component: require('./components/listing/show.vue')
}
]
},
...
]
});