小程序引入评价发布组件
2023-08-06 本文已影响0人
清风昙
引入评价发布组件,代码引入实现:
1.在app.json引入评价发布组件
{
"plugins": {
"wxacommentplugin": {
"version": "1.0.1",
"provider": "wx82e6ae1175f264fa"
}
}
}
注:必须填该评价组件appid,该示例值即为评价组件appid(复制时请去掉注释)
如果还未添加插件,则在开发者工具Console里点击「添加插件」。



2.在某页面对应的js文件里面调用组件接口
如在页面加载onLoad时就调用评价发布组件
onLoad: function (options) {
var plugin = requirePlugin("wxacommentplugin");
plugin.openComment({
// wx_pay_id: '4200001729202306024807578', // 交易评价类账号,选填
success: (res)=>{ // 评价成功的回调
console.log('plugin.openComment success', res)
},
fail: (res) =>{ // 评价失败的回调
console.log('plugin.openComment fail', res)
}
})
}
3.实现效果
