Vuejs2 路由器链路中的初始参数设置是什么

Vuejs2 路由器链路中的初始参数设置是什么,vuejs2,vue-router,Vuejs2,Vue Router,我正在尝试使用Vuejs提供服务。 这是路由器链接,我想用每个用户的ID创建一个动态url。 如您所见,命名路由“profile”具有初始参数“0”。 但是,我不需要输入“0”,因为当用户发布ajax请求时,将需要此参数 重新启动PI控制器功能 →索引()…getAllUsersProfiles() →显示($id)…getUsersProfileById($id) 首先,我在路由器链接中尝试了{user_id:},但是返回了“../profile/list/undefined”,当然我不能调用

我正在尝试使用Vuejs提供服务。 这是路由器链接,我想用每个用户的ID创建一个动态url。 如您所见,命名路由“profile”具有初始参数“0”。 但是,我不需要输入“0”,因为当用户发布ajax请求时,将需要此参数

重新启动PI控制器功能

→索引()…getAllUsersProfiles()

→显示($id)…getUsersProfileById($id)

首先,我在路由器链接中尝试了{user_id:},但是返回了“../profile/list/undefined”,当然我不能调用api。无论如何,即使参数“0”与用户id不匹配,我也必须将一些数字作为初始参数以避免“未定义”

index.vue

<router-link tag="li" :to="{name: 'profile', params: {user_id : '0'}}"><button class="btn btn-success">profile</button></router-link>

有没有办法在一条路由中处理“”案例和“2或3或…(用户id)”案例?

您的路由器链接组件正在尝试链接到一条名为
的路由,该路由的
名称为
'profile'
。但是,你没有这个名字的路线。你是说
“个人资料”
?是的,抱歉弄错了。嗯……有什么想法吗?我不知道你在问什么。似乎您想知道您的
ProfileList
组件应该如何处理其
user\u id
参数。但我真的不知道。你能澄清你的问题吗?
const router = new VueRouter({
    mode: 'history',
    routes: [
        { path: '*', component: NotFoundComponent },
        { path: '/top', name: 'top', component: require('./components/TopView.vue') },
        { path: '/profile/list/:user_id', name: 'profile', component: require('./components/ProfileList.vue') },
    ]
})