提问人:Saruhan 提问时间:11/10/2023 更新时间:11/10/2023 访问量:41
我想使用 Vue Router 将 ID 作为参数传递,但我遇到了麻烦
I want to pass an ID as a params with Vue Router, but I'm having trouble
问:
我有一个文章视图和sideBarRight组件。
在 SideBarRight 组件中 -
<v-chip-group>
<v-chip v-for="tag in tags" :key="tag" :item-id="tag.id" @click="chipClick(tag.id)">
{{ tag.articleName }}
</v-chip>
</v-chip-group>
.
.
.
methods:{
chipClick(itemId) {
this.$router.push({name: 'article', params: { itemId }});
}
}
我的路由器如下所示:
{
path: "/article/:itemId",
name: "article",
component: () =>
import("../views/ArticleView.vue")
}
我想在单击筹码时进行导航并将 itemId 传递给视图。我不确定如何实现这一目标。有没有特定的钩子?
答: 暂无答案
评论
this.$route.params
this.$router.push( { name: 'article', params: { itemId: itemId } } );
beforeRouteEntered
data():{ return { content: "" } }, beforeRouteEntered(to, from, next){ // I get the data from api and I pass the html content but this.content = apiResult.data.content; // but this is not worked. }
this.content
this
created()
mounted()