0.1.2 • Published 5 years ago

@autofe/share v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Share

Usage

样式请自己写,该库对 HTML 的惟一要求就是必须有几个分享按钮的样式类名,可以是 share-wechatshare-weiboshare-friendshare-qzoneshare-qq

<div class="share">
  <button type="button" class="share-wechat">
    微信
  </button>
  <button type="button" class="share-weibo">
    新浪微博
  </button>
  <button type="button" class="share-friend">
    朋友圈
  </button>
  <button type="button" class="share-qzone">
    QQ空间
  </button>
  <button type="button" class="share-qq">
    QQ好友
  </button>
</div>

通过脚本初始化

$('.share').share({
  shareTitle: '分享标题',
  shareUrl: 'https://m.autohome.com.cn/',
  sharePic: 'https://www3.autoimg.cn/newsdfs/g12/M12/B4/C9/400x300_0_autohomecar__wKjBy1g_CemAHZEvAAGyJet9vxY587.JPG',
  shareSummary: '分享描述',
});

Options

参数可以通过 data attributes 或者 JavaScript 两种方式来配置.

NameTypeDefaultDescription
shareTitlestringdocument.title分享标题
shareUrlstringdocument.location.href分享链接
sharePicstring分享配图
shareSummarystring分享内容

End

Thanks to Bootstrap