vue中把一个页面的值传到下一个新的页面中

项目场景:

购物车


解决方案:

方式一
前一个界面
  this.$router.push(
                    {
                        //添加需要传值到那个页面的路径
                        path:'/PayView',
                        //携带需要传递的参数 第一个id是参数的名字 第二个是参数
                        query:{id:id}
                    })
新的界面
 methods:{
            getId(){
                var id = this.$route.query.id;
                console.log(id);

            }
        }
方式二
前一个界面
this.$router.push({
	// 跳转到的页面名
    name: 'PayView',
    // 传递的参数集合
    params: {
      detailData: data
    }
})
新的界面
created(){
	this.detailData = this.$route.params.detailData
}


猜你喜欢

转载自blog.csdn.net/qq_55648724/article/details/128686038