1封装一个支付弹框组件
这是页面引用代码
js部分
data(){
return { //这是组件配置的数据部分
couponarr: [],
showpopup :false,
couponYes: ‘1张可用’,
couponNo: ‘暂无优惠券’,
couponID: ‘’,
money: ‘’,
}
}
methods:{ //这是给组件配置的方法部分
popup () {
this.showpopup = true
},
close () {
this.showpopup = false
},
confirmPay () {
this.getOrder()
},
payVip () {
this.KaTeX parse error: Expected 'EOF', got '}' at position 40: …r/vip'}) }̲, readCou…router.push({name: ‘ChannelCoupon’,
params: {
couponYes: this.retailPrice,
couponarr: this.couponarr
}})
}
}
在页面有部分数据的情况下,在请求部分数据的方法中放入以下代码
if (that.KaTeX parse error: Expected '}', got 'EOF' at end of input: … = '-¥' + that.route.params.money
} else if (that.KaTeX parse error: Expected '}', got 'EOF' at end of input: … = '-¥' + that.route.params.couponPrice
} else {
that.couponYes = that.couponarr.length + ‘张可用’
}
在我们去的优惠券列表页面展示如下代码
回到对应的页面之后
created: function () {
this.getDes()
if (this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …ouponID = this.route.params.couponID
this.money = this.KaTeX parse error: Expected 'EOF', got '}' at position 26: …ms.money }̲ console.…route.params)
},
这里主要是通过
this.$router.push({
name: ‘FiveOfYearPayment’,
params: {
couponPrice: this.couponPrice,
couponID: this.couponID,
money: this.money
}
})
来动态传值,
this.$route.params来动态获取数据