参数正确,接口支持,网站为什么无法分享?
发布于 6 年前 作者 xiulan46 3632 次浏览 来自 问答

使用 jweixin 实现将网站分享到朋友圈的过程中(jweixin是1.4.0):

参数正确:

接口支持:

我将分享事件绑定在button的click事件下:

这是我的button:

<button type="button" class="btn btn-outline-light btn-lg text-dark" id="shareToWeChat">
      <i class="fa fa-weixin" style="color: #4da43b;"></i> 分享至朋友圈
</button>

这是我的点击事件:

wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
 
    wx.checkJsApi({
        jsApiList: ['onMenuShareTimeline'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
        success: function(res) {
            console.log(res);
        }
    });
 
    $("#shareToWeChat").click(function () { //分享到朋友圈
        wx.onMenuShareTimeline({
            title: '测试标题', // 分享标题
            desc: '测试描述', // 分享描述
            link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: '__M__PRODUCT__/groups/{$product.productid}/poster.jpg', // 分享图标
        }, function(res) {
            console.log(res);
        //这里是回调函数
        });
    });
 
 
});

为什么无法分享呢?

恳请大神赐教!跪谢!

回到顶部