vue中进行微博分享的实例讲解
1、首先要在页面写出点击可进行微博分享的入口,样式因自己项目而定:
微博
2、其次,对微博按钮进行点击事件,也就是最重要的进行微博分享的操作:
//微博分享 $('.shareSina').on('click',function(){ window.sharetitle=$(".print-tit").html();//分享的标题 window.shareUrl=$(".myShareimg").attr('src');//分享显示的图片 share(); }) functionshare(){ (function(s,d,e){ try{}catch(e){} varf='http://v.t.sina.com.cn/share/share.php?', u=window.location.href, p=['url=',e(u),'&title=分享的名称','&pic=',e(window.shareUrl)].join(''); functiona(){ if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=620,height=450,left=',(s.width-620)/2,',top=',(s.height-450)/2].join('')))u.href=[f,p].join(''); }; if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()} })(screen,document,encodeURIComponent); }
点击后会出现一个新弹窗的页面,页面内含有你要分享的图片及网站的名称、详情等,页面会跳转到新浪微博,如果你已经登录微博,那么会直接分享成功,如果没有登陆,会跳转到登录页面,登陆后直接分享成功。
3、这样微博就分享成功了!
以上就是本次介绍的全部知识点内容,感谢大家的学习和对毛票票的支持。