hexo next主題深度優化(四),自定義一個share功能,share.js。


我的博客: https://mmmmmm.me
源碼: https://github.com/dataiyangu/dataiyangu.github.io

背景:

以前一直用的addthis或者百度分享,但是加入pjax後失效,相應的接口重寫也不行,故本身從新加一個分享的功能。java

開始:

引入資源:

hexo next主題深度優化(三),引入require.js,適配pjax。

代碼

var $config = {
  sites : ['weibo','qq', 'wechat','tencent','qzone','douban', 'facebook',  'google','twitter'],
  disabled: [ 'linkedin', 'diandian'],
  wechatQrcodeTitle: "微信掃一掃",
  wechatQrcodeHelper: '<p>微信掃一掃,右上角分享</p>',
  source: 'Leesin Dong'
};


$('.post-spread').share($config);

function pjaxshare() {
  $('.post-spread').share($config);
}

關鍵的一步

不少時候出現:
在這裏插入圖片描述
這是什麼鬼?
下載網上的demo發現了問題。缺乏雪碧圖把?(猜測)
經過對比,須要引入demo中的fonts目錄。
在這裏插入圖片描述git

附:方便學習的小demo

https://github.com/overtrue/share.js/zipball/mastergithub

一次成功後還出現上面的bug

將fonts目錄刪掉,從新導入web

結束

2018.12.23發現bug(讀者可忽略)

裏面的圖標變成了灰色,由於在護眼的js中對a標籤的顏色進行了從新定義,加a:not()微信

相關文章
相關標籤/搜索