【问题标题】:Missing param for named route: Expected "x" to be defined命名路由缺少参数:应定义“x”
【发布时间】:2018-06-02 12:17:52
【问题描述】:

我是否这样做

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 }
    }

导致问题的原因是什么?我的设置没有任何问题,我正在做文档中的所有事情。 谢谢。

【问题讨论】:

    标签: vue.js vue-router vuex


    【解决方案1】:

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

    所以要解决这个问题,请将您的路由器链接包装在 v-if 中。

    对相同错误的更好解释的参考在这里:

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

    【讨论】:

    • 我通常每次都会得到这个答案:)
    猜你喜欢
    • 2019-07-24
    • 1970-01-01
    • 2020-04-30
    • 2018-09-20
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 2019-12-14
    • 1970-01-01
    相关资源
    最近更新 更多