Facebook 分享按钮和评论插件冲突
在我的博客中,我需要实现 Facebook 分享按钮(带有计数器)和评论插件。我刚刚使用了下面的代码。
FACEBOOK SHARE
<a
name="fb_share"
type="button_count"
href="http://www.facebook.com/sharer.php">
Share
</a>
<script
src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
type="text/javascript">
</script>
FACEBOOK COMMENT PLUGIN
<div id="fb-root"></div>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-num-posts="2" data-width="524"></div>
最后返回错误
未捕获的类型错误:对象#没有方法“提供”
on line 4,并且此错误不显示评论插件。它显示的是共享按钮。
这个问题有什么解决办法吗?
In my blog I need to implement both a Facebook share button (with a counter) and comment plugin. I just used the code below.
FACEBOOK SHARE
<a
name="fb_share"
type="button_count"
href="http://www.facebook.com/sharer.php">
Share
</a>
<script
src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
type="text/javascript">
</script>
FACEBOOK COMMENT PLUGIN
<div id="fb-root"></div>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-num-posts="2" data-width="524"></div>
In the end, it returns the error
Uncaught TypeError: Object # has no method 'provide'
on line 4, and this error don't show the comment plugin. It shows instead the share button.
Is there any solution to this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了完全相同的问题。我最终不得不切换我正在使用的 FB 插件。
这是我网站的链接,其中包含评论和点赞按钮:
http://www.jhousemedia .com/blog-articles/145/Building-A-Good-Website-For-Your-Business.html
我必须使用 Like/Send 插件切换共享按钮。幸运的是,他们可以选择使其适合与共享按钮类似的形式。
这是使用的插件
http://developers.facebook.com/docs/reference/plugins/like/
I had the exact same problem. I ultimately had to switch which FB plugin I was using.
Here's the link to my site where I have the comments and the like button together:
http://www.jhousemedia.com/blog-articles/145/Building-A-Good-Website-For-Your-Business.html
I had to switch out the share button with the Like/Send plugin. Fortunately, they have an option to make it fit a similar form as the share button.
Here's the plugin used
http://developers.facebook.com/docs/reference/plugins/like/
我不确定,但您可以尝试评论或删除此行:
也许共享和评论脚本是重复的代码。
I'm not sure, but you can try to comment or delete this line:
Maybe share and comment scripts are duplicating code.
通过将注释脚本替换为标题中的这一行来解决此问题
Solved this by replacing the comments script with just this line in the header