Pass the value of a page to the next new page in vue

Project scenario:

shopping cart


solution:

方式一
前一个界面
  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
}


Guess you like

Origin blog.csdn.net/qq_55648724/article/details/128686038