前端Vue页面之间传递参数
1、使用router对象传递。传参:this.$router.push({name:"下一页面的路由name",params:{参数1:值1,参数2:Json.stringify(对象类型的值)}});或者this.$router.push({path:"/user/${userId}"});接收参数:this.$route.params.参数1或Json.parse(this.$route.pa
·
1、使用router对象传递。
传参:
this.$router.push({name:"下一页面的路由name",params:{参数1:值1,参数2:Json.stringify(对象类型的值)}});
或者
this.$router.push({path:"/user/${userId}"});
接收参数:
this.$route.params.参数1
或
Json.parse(this.$route.params.参数2)
或
this.$route.params.userId
2、使用Storage对象传递,例如SessionStorage对象
sessionStorage.setItem("key",value);
sessionStorage.getItem("key");
sessionStorage.removeItem("key");
3、使用vuex传递参数
使用方式见Vue官方文档vuex组件使用https://vuex.vuejs.org/zh/guide/
更多推荐
已为社区贡献3条内容
所有评论(0)