vue分享
Posted liujiajiablog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue分享相关的知识,希望对你有一定的参考价值。
如图:
一: 安装share.js
npm install social-share.js
二:刚进来初始化
setTimeout(() => { this.setShare(); }, 0);
setShare() { let random = parseInt(Math.random() * 10000); this.urlParam = "http://www.xxxxxxx.com/share/index.html?stuWorkid=" + data+ "&schoolcode=" + this.$store.state.schoolcode + "&random=" + random; console.log(this.urlParam) //分享相关代码 window._bd_share_config = { common: { bdText: "我要分享", bdDesc: "我也要分享", bdUrl: this.urlParam }, share: [ { bdSize: 32 } ] }; console.log(window._bd_share_config) var s = document.createElement("script"); s.type = "text/javascript"; s.id = "scriptJs"; s.src = "http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=" + ~(-new Date() / 36e5); console.log(s.src) document.body.appendChild(s); window._bd_share_main.init(); }
三:布局
<div class="bdsharebuttonbox"> <img src="../assets/img/weixin.png" data-cmd="weixin" title="分享到微信"/> <img src="../assets/img/weibo.png" data-cmd="tsina" title="分享到新浪微博"/> <img src="../assets/img/gengduo.png" data-cmd="more" title="更多"/> </div>
----------END
以上是关于vue分享的主要内容,如果未能解决你的问题,请参考以下文章