博主原创:未经博主允许,不得转载

在做项目的时候,碰到实现分享的功能,在网上搜了很多的资料,实现分享主要有两种插件。

一种插件是百度分享的插件,另一种是jiathis进行实现分享。

先展示用百度分享插件如何实现,具体代码如下,其实现的功能为实现视频分享,并带视频图片:

<body>
<div class="bdsharebuttonbox" data-tag="share_1">
<a class="bds_weixin" data-cmd="weixin"></a>
<a class="bds_qzone" data-cmd="qzone"></a>
<a class="bds_tsina" data-cmd="tsina"></a>
<a class="bds_baidu" data-cmd="baidu"></a>
<!-- <a class="bds_tqq" data-cmd="tqq"></a> -->
<a class="bds_sqq" data-cmd="sqq"></a>
<a class="bds_more" data-cmd="more">更多</a>
<a class="bds_count" data-cmd="count"></a>
</div>
<script>
window._bd_share_config = {
"common" : {
"bdSnsKey" : {},
"bdText" : "${title}", //分享时的标题
"bdMini" : "2",
"bdMiniList" : false,
"bdPic" : "${pic}", //此处为分享时自带的图片
"bdStyle" : "0",
"bdSize" : "32",
"bdUrl" : '${sharUrl}', //此处为后台要进行分享的内容的定义
"bdDesc":'${summary}', //分享时的文本摘要
},
"share" : {}
};
//此处为需要引入的百度分享的js文件
with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion='+~(-new Date()/36e5)];
</script>


</body>
</html>

实现后的效果为:

实现分享功能插件一---百度分享插件应用_分享功能

应用以上的代码就可以简单的实现一个内容的分享功能。

如果要实现更多的功能,可以参考百度分享的官网:http://share.baidu.com/code/advance