[路由器推入在我想传递参数时在vuejs中不起作用

问题描述 投票:0回答:1

[当我想通过vue-router包使用编程导航时,它可以工作,但是当我想通过router.push方法将参数传递给组件时,它根本不起作用。有人有解决办法吗?

我的代码在这里:

import VueRouter from 'vue-router'
import routes from './routes';

const router = new VueRouter({routes});

Vue.use(VueRouter);

和推送代码:

router.push({ name: 'reportArchive', params: {token: token} });

我的路线配置:

{ path: '/reportArchive', name: 'reportArchive', component: reportArchive },
javascript vue.js vuejs2 vue-component router
1个回答
0
投票

您的路线定义不接受参数。您应该如下定义路线:

{ path: '/reportArchive/:token', name: 'reportArchive', component: reportArchive },
© www.soinside.com 2019 - 2024. All rights reserved.