wx.miniapp.shareImageMessage

分享图片到微信

注:

1、该接口需要申请和初始化微信 open 能力,需要客户端进行相关配置

2、该接口不支持在「移动应用助手」中调试,开发者需构建 apk 或者 ipa 安装到手机后才能调试

接入前注意事项

参数

方便开发者理解,wx.miniapp.shareImageMessage 参数与微信开放平台 opensdk 分享接口open in new window参数一致

属性类型默认值必填说明
imagePathstring-分享图片,支持代码包图片资源路径或者本地临时、缓存、用户文件;不支持网络图片路径
thumbPathstring-分享缩略图,支持代码包图片资源路径或者本地临时、缓存、用户文件;不支持网络图片路径
scenenumber-发送的目标场景,0=分享到会话,1=分享到朋友圈,2=分享到收藏

调用示例

wx.miniapp.shareImageMessage({
  imagePath: '/pages/share.png',
  thumbPath: '/pages/thumb.png',
  scene: 0, 
  success(res) {
    wx.showToast({
      title: '成功:分享图片',
    })
  },
  fail() {
    wx.showToast({
      title: '失败:分享图片',
    })
  }
})