命名路由缺少参数:需要定义 "x"

Missing param for named route: Expected "x" to be defined

我是否这样做

Vue.router.push({ path: '/beats/catalog/1' }) 

或这个

Vue.router.push({ name: 'BeatsCatalog', params: { page: 1 } })

我得到相同的结果: [vue-router] missing param for named route "BeatsCatalog": Expected "page" to be defined.

路由器:

{
        path: '/beats',
        components: {
            navbar: Navbar,
            default: { template: `<router-view/>` }
        },
        children: [{
                name: 'BeatsCatalog',
                path: 'catalog/:page',
                components: {
                    default: () => import('@/views/BeatsCatalog')
                },
                props: { default: true }
            },
            {
                path: 'upload',
                name: 'BeatsUpload',
                components: {
                    default: () => import('@/views/BeatsUpload')
                }
            },
        ],
        meta: { requiresAuth: true }
    }

是什么导致了这个问题?我没有发现我的设置有任何问题,我正在按照文档中的方式进行所有操作。 谢谢。

@贾科马, 在组件 BeatsCatalog 上的数据 属性 中,页面在初始加载时未定义。因此你得到了错误。

所以要解决这个问题,请将您的 router-link 包裹在 v-if 中。

对同一错误的参考和更好的解释在此处:

https://github.com/vuejs/vue-router/issues/986