vue路由中怎么传入数据
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
<router-link :to="{ path: './list/learn'}" tag="section" class="item">
<img src="../assets/h5_icon_1.png" alt="Subject Learn">
<p>It is a learning fairyland for Chinese learners</p>
</router-link>
child.vue
created(){
this.fetch();
this.title = this.$route.params.category.toUpperCase();
}
详情可以去看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
<router-link :to="{ path: './list/learn'}" tag="section" class="item">
<img src="../assets/h5_icon_1.png" alt="Subject Learn">
<p>It is a learning fairyland for Chinese learners</p>
</router-link>
child.vue
created(){
this.fetch();
this.title = this.$route.params.category.toUpperCase();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询