QQ的二次分享

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
方法一:<br>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);      <br>$("meta[name='image']").attr('src',"http://zmall.hazq.com:8295/m/tgwd/images/huiying.png"); <br>$("meta[name='image']").attr('content',"http://zmall.hazq.com:8295/m/tgwd/images/huiying.png");

  

1
2
3
4
5
6
7
8
9
10
11
12
方法二:使用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,最好这两种方法都在页面中使用。

posted @   杰_森  阅读(812)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示