支付宝小程序API 分享
支付宝小程序API 分享
onShareAppMessage
在 Page 中定义 onShareAppMessage 函数,设置该页面的分享信息。
- 只有在 Page 中重写了 onShareAppMessage 函数,才会在每个Page页面的右上角菜单中显示“分享”按钮。默认分享当前 Page 的页面信息。
- 用户点击分享按钮的时候会调用。
- 此事件需要 return 一个 Object,用于自定义分享内容。
Object 参数说明
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
title | String | 是 | 自定义分享标题 |
desc | String | 否 | 自定义分享描述 |
path | String | 是 | 自定义分享页面的路径,path中的自定义参数可在小程序生命周期的onLoad方法中获取(参数传递遵循http get的传参规则) |
success | Function | 否 | 分享成功后回调 |
fail | Function | 否 | 分享失败后回调 |
complete | Function | 否 | 分享后回调 |
代码示例
Page({
onShareAppMessage() {
return {
title: '小程序示例',
desc: '小程序官方示例Demo,展示已支持的接口能力及组件。',
path: 'page/component/component-pages/view/view?param=123'
};
},
});