[当我想通过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 },
您的路线定义不接受参数。您应该如下定义路线:
{ path: '/reportArchive/:token', name: 'reportArchive', component: reportArchive },