// 传参
toDetail(){
this.$router.push({
name:"newsDetail",
params:{content:item}//传递过去的参数
})
}
// 取参
this.$route.params.comtent
这种参数会丢失
// 传参
this.$router.push({
path: "/newsDetail",
query: {
content: JSON.stringify(item),
},
});
// 取参
this.$route.query.comtent // json记得转换
这种不会丢失
// 路由配置
{
path: "workDetail/:id",
name: "WorkDetail",
component: () => import("@/page/workDetail")
}
// 跳转事件
getDetail(id) {
this.$router.push("/workDetail/" + id);
},
也不会丢失