QQ的二次分享

时间:2019-09-17
本文章向大家介绍QQ的二次分享,主要包括QQ的二次分享使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

 

方法一:
QQ分享会直接取页面中的meta中的值,注意meta的写法和属性 //页面头部写上以下meta标签 <meta name="title" content="今年双十二应该不会像去年那样惨?"> <meta itemprop="name" content="今年双十二应该不会像去年那样惨?"> <meta name="description" itemprop="description" content="张译文的观点"> <meta itemprop="image" name="image" src="http://zmall.hazq.com:8295/m/tgwd/images/huiying.png" content="http://zmall.hazq.com:8295/m/tgwd/images/huiying.png"> //页面刚开始位置写上一个隐藏的img标签,路径和分享出去的图片一致,避免qq分享直接取页面第一张图片 <div class="share" style="display:none;"> <img src="http://soft.thinkive.com/h5/huaanzx/news/images/weiyapp.png"> </div> 注:如果你的页面分享出去的数据是动态的,那么content需要随便写上一个值然后再重新赋值,不能默认为空,不然重新赋值不起作用 $("meta[name='description']").attr('content',opinionParam.employeename+"的观点"); $("meta[name='title']").attr('content',opinionParam.title); $("title").html(opinionParam.title); $("meta[itemprop='name']").attr('content',opinionParam.title);
$("meta[name='image']").attr('src',"http://zmall.hazq.com:8295/m/tgwd/images/huiying.png");
$("meta[name='image']").attr('content',"http://zmall.hazq.com:8295/m/tgwd/images/huiying.png");

  

方法二:使用QQ的sdk
<script type="text/javascript" src="//open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script>
//QQ的二次分享
    function qqShare(){
	var pageURL = 'http://soft.thinkive.com/h5/huaanzx/tgwd/index.html#!/personalStore/opinionDetail.html?opinion_id=93';
    	  mqq.data.setShareInfo({
		title:opinionParam.title, // 分享标题
		desc :opinionParam.employeename+"的观点", // 分享内容
		image_url :"http://zmall.hazq.com:8295/m/tgwd/images/huiying.png", // 分享图片
		share_url:pageURL, // 分享链接
	},function(){});
    }

  注:为了适应安卓和ios,最好这两种方法都在页面中使用。

原文地址:https://www.cnblogs.com/deng-jie/p/11532267.html