我使用以下代码,您需要在 foreach 中实现,并更改data-href
<div id="fb-root" style="display:none"></div>
<script type="text/javascript">
(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/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="false" data-href="<?php echo $someUrl; ?>"></div>