可以直接把下面这段js写成 wx.js 然后在页面里面调用,也可以直接写在页面上
function onBridgeReady() {var mainTitle="分享啦!",mainDesc="分享说明",mainURL="",//url的绝对地址mainImgUrl= "/141717132878646.jpg";//图片的绝对地址//转发朋友圈WeixinJSBridge.on("menu:share:timeline", function(e) {var data = {img_url:mainImgUrl,img_width: "120",img_height: "120",link: mainURL,//desc这个属性要加上,虽然不会显示,但是不加暂时会导致无法转发至朋友圈,desc: mainDesc,title: mainTitle};WeixinJSBridge.invoke("shareTimeline", data, function(res) {WeixinJSBridge.log(res.err_msg)});});//同步到微博WeixinJSBridge.on("menu:share:weibo", function() {WeixinJSBridge.invoke("shareWeibo", {"content": mainDesc,"url": mainURL}, function(res) {WeixinJSBridge.log(res.err_msg);});});//分享给朋友WeixinJSBridge.on('menu:share:appmessage', function(argv) {WeixinJSBridge.invoke("sendAppMessage", {img_url: mainImgUrl,img_width: "120",img_height: "120",link: mainURL,desc: mainDesc,title: mainTitle}, function(res) {WeixinJSBridge.log(res.err_msg)});});};//执行document.addEventListener('WeixinJSBridgeReady', function() {onBridgeReady();});