问题现象
点击 Button 会唤起分享弹框,但是不会触发定义的 onShareAppMessage 事件,无法定义分享卡片的内容。
原因
分享行为是基于页面维度的。在 page.json 定义的页面中声明的 onShareAppMessage 才是有效的,如果你在组件中声明了 onShareAppMessage 是不会在分享 Button 点击时触发的。实际上,如果你在组件中声明了 onShareAppMessage,那么该组件对应的页面也是不能从右上角功能按钮进行分享的。
措施
把在组件内定义的 onShareAppMessage 挪到外层页面