vue路由中怎么传入数据

2025-04-13 01:51:20
推荐回答(1个)
回答1:

动态路由,然后用$route.params去获取路由对象里的信息
详情可以去看vue router的官方文档
下面是我最近写的例子
route.js

export default new Router({
routes: [
{
path: '/',
name: 'index',
component: index
},
{
path: '/list/:category',
name: "list",
component: list,
meta: { id: 'list-kind' }
}
]
})
parent.vue


Subject Learn

It is a learning fairyland for Chinese learners



child.vue

created(){
this.fetch();
this.title = this.$route.params.category.toUpperCase();
}