在A页面里利用$router.push({path:'/views/purchase', query: {orderID: res}});跳转到purchase页面,在purchase页面获取不到A页面传过来的值。
A页面的代码:
this.$hprose1.mashangmai(token,product_id,num, Sku_id, ).then(function (res) {
console.log('订单ID', res)
that.$router.push({path:'/views/purchase', query: {orderID: res}});
// that.orderID = res
},function(err){
console.log(err);
});
purchase页面获取参数的代码:
mounted() {
that.$route.query.orderID
}
,然后就一直获取不到,显示undefined,只有在mounted里写一个延时器才能获取到A页面传过来的参数,求解。
mounted里面调用vue实例下面的路由参数不是用this吗?