manifest.json
对应支付宝小程序的app.json
{
"name" : "app-name",
"appid" : "__UNI__000000",
// ...
"mp-alipay": { // 支付宝小程序部分
"appid" : "2021xxxxxxxxx000",
"component2" : true,
"plugins" : {
// 静态注册插件
"couponPlugin" : { // 组件名可以自己起
"version" : "*",
"provider" : "20210xxxxxxxxxx" // 插件id
}
}
}
}
pages.json
对应支付宝小程序页面json
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "首页",
"mp-alipay": {
"usingComponents": {
"get-coupon": "plugin://couponPlugin/get-coupon" // 注册组件,组件名可自定义
}
}
}
}
index.vue
<template>
<get-coupon :params="coupon_params"
onGetCouponSuccess="onGetCouponSuccess">
<!-- 事件监听按照支付宝小程序语法,不用`@` -->
</get-coupon>
</template>
export default {
data() {
return {
coupon_params: []
}
},
onLoad() {
// 绑定事件监听
this.$scope.onGetCouponSuccess = this.onGetCouponSuccess.bind(this)
},
methods: {
onGetCouponSuccess(e) {
console.log("领券成功", e)
}
}
}