注意:分享图片 命名 最好不用驼峰命名 例如:preShare.png/jpg
meta头信息
<meta property="og:url" content="url" />
<meta property="og:type" content="website" />
<meta property="og:title" content="title" />
<meta property="og:description" content="description" />
<meta property="og:image" content="分享图片路径" />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@nytimes">
<meta name="twitter:creator" content="@SarahMaslinNir">
<meta name="twitter:title" content="title">
<meta name="twitter:description" content="description">
<meta name="twitter:image" content="分享图片路径">
fb分享
function shareFbUrl(shareObj){
FB.ui({
display: 'popup',
method: 'share',
href: _URL_PATHNAME,//分享地址路径
}, function(response){
if(response){
// tipOpen("fail", 2000)
}else{
// tipOpen("succeed", 2000)
}
});
}
twitter分享
function shareTwUrl(title=''){
window.open('http://twitter.com/share?url=' + encodeURIComponent(_URL_PATHNAME) + '&text=' + encodeURIComponent(title), '', 'left=0,top=0,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0')
}