wx.miniapp.shareWebPageMessage

分享网页到微信

注:

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

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

接入前注意事项

参数

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

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

JSAPI 代码例子

wx.miniapp.shareWebPageMessage({
    title: '网页标题',
    description: '网页描述',
    thumbPath: '/pages/thumb.png',
    webpageUrl: 'www.qq.com',
    scene: 0, 
    success(res) {
        wx.showToast({
            title: '成功:分享网页',
        })
    },
    fail() {
        wx.showToast({
            title: '失败:分享网页',
        })
    }
})