如何正确使用小程序分享链接的onShareAppMessage方法?
- 内容介绍
- 相关推荐
本文共计1057个文字,预计阅读时间需要5分钟。
使用onShareAppMessage方法实现分享功能,只需在button标签中加入open-type=share,小程序UI将自动识别分享链接功能。
javascriptonShareAppMessage: function(opt) { // 分享逻辑}
onShareAppMessage用法:
只需要在button标签中加入open-type="share",小程序ui就会自动识别分享链接功能
<button data-name="shareBtn" open-type="share">分享</button>
js中代码如下:
onShareAppMessage: function( options ){ var that = this; // 设置菜单中的转发按钮触发转发事件时的转发内容 var shareObj = { title: "转发的标题", // 默认是小程序的名称(可以写slogan等) path: '/pages/share/share', // 默认是当前页面,必须是以‘/'开头的完整路径 imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。
本文共计1057个文字,预计阅读时间需要5分钟。
使用onShareAppMessage方法实现分享功能,只需在button标签中加入open-type=share,小程序UI将自动识别分享链接功能。
javascriptonShareAppMessage: function(opt) { // 分享逻辑}
onShareAppMessage用法:
只需要在button标签中加入open-type="share",小程序ui就会自动识别分享链接功能
<button data-name="shareBtn" open-type="share">分享</button>
js中代码如下:
onShareAppMessage: function( options ){ var that = this; // 设置菜单中的转发按钮触发转发事件时的转发内容 var shareObj = { title: "转发的标题", // 默认是小程序的名称(可以写slogan等) path: '/pages/share/share', // 默认是当前页面,必须是以‘/'开头的完整路径 imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。

