相关疑难解决方法(0)

Vue.js使用默认子级嵌套路由

我在Vue.js 2中遇到了默认子路由的问题.

当我最初访问localhost/listing时,它正确地将index.vue和map.vue加载为子级.

当我使用router-link导航到localhost/listings/1,然后使用router-link返回localhost/listing时,它仍然会加载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')
                }
            ]
        },

        ...

    ]
});
Run Code Online (Sandbox Code Playgroud)

vue.js vuejs2

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

vue.js ×1

vuejs2 ×1