最新的微信JSSDK分享接口是不是有问题呀?还是我的代码哪里错了?怎么无法自定义分享内容。
代码是这样的:
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
wx.config({
debug: true,
appId: "wx02d04c1b737190fe",
timestamp: "1421290950",
nonceStr: "DArR9zORKGhde7AS",
signature: "ef1ffc35b7b1b3e22b65994edc2d1546a1016b0f",
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo'
]
});
wx.ready(function () {
wx.checkJsApi({
jsApiList: [
'onMenuShareTimeline',
]
});
wx.onMenuShareTimeline({
title: '互联网之子',
link: 'http://wx.vland.cc/mobile.php?act=module&rid=406&fromuser=oktsYuHivHXuzdsMeCbWyF7b14UU&name=hllihe&do=sharelihe&weid=7',
imgUrl: 'http://wx.vland.cc/resource/attachment/images/7/2015/01/fl2Lk2p5o3iOJP3jdp9iPXI9i93iPm.jpg',
trigger: function (res) {
alert('用户点击分享到朋友圈');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert('wx.onMenuShareTimeline:fail: '+JSON.stringify(res));
}
});
});
wx.error(function (res) {
alert('wx.error: '+JSON.stringify(res));
});
</script>
因为打开了调试模式,弹出调试信息 说明配置没问题:
又弹出了checkJsApi,说明客户端支持这个接口:
然后就没有别的弹出了……
分享到朋友圈:
标题还是那个标题,并没有变成自定义的“
互联网之子
”,这是为什么?
微信开发 微信分享代码 html5 微信公众平台 JavaScript
Answers
wx.onMenuShareTimeline({
title: '互联网之子',
link: '
http://wx.vland.cc/mobile.php?act=module&rid=406&fromuser=oktsYuHivHXuzdsMeCbWyF7b14UU&name=hllihe&do=sharelihe&weid=7
',
imgUrl: '
http://wx.vland.cc/resource/attachment/images/7/2015/01/fl2Lk2p5o3iOJP3jdp9iPXI9i93iPm.jpg
',
trigger: function (res) {
alert('用户点击分享到朋友圈');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert('wx.onMenuShareTimeline:fail: '+JSON.stringify(res));
}
});
你可以绑定到一个按钮点击事件上面,或者和上面说的一样 延迟加载
把
wx.onMenuShareTimeline({
title: '互联网之子',
link: 'http://wx.vland.cc/mobile.php?act=module&rid=406&fromuser=oktsYuHivHXuzdsMeCbWyF7b14UU&name=hllihe&do=sharelihe&weid=7',
imgUrl: 'http://wx.vland.cc/resource/attachment/images/7/2015/01/fl2Lk2p5o3iOJP3jdp9iPXI9i93iPm.jpg',
trigger: function (res) {
alert('用户点击分享到朋友圈');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert('wx.onMenuShareTimeline:fail: '+JSON.stringify(res));
}
});
把这段代码,封装成个函数,然后用settimeout延迟2秒加载试试。