FastComments.com Blog

Wed Feb 12 2020
...

在同一页面多个地方使用 FastComments

FastComments 是灵活的。它可以附加到页面上的一个常规元素,因此可以与任何网页框架一起使用。

这意味着我们可以在页面上拥有任意数量的线程。例如,这里有两个并排的线程。

它是如何工作的

这是实现此功能的代码。我们自定义 urlId 参数以使每个线程唯一。请注意,我们使用 ids,您可以以任何您喜欢的方式传入查询的 DOM 元素。

<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script> <div class="widgets"> <div class="widget left" id="fastcomments-widget2"></div> <div class="widget right" id="fastcomments-widget3"></div> </div>

<script> window.FastCommentsUI(document.getElementById('fastcomments-widget2'), { tenantId: 'L177BUDVvSe', urlId: window.location.href + '?cats', headerHTML: '<h1>讨论猫</h1>' }); </script> <script> window.FastCommentsUI(document.getElementById('fastcomments-widget3'), { tenantId: 'L177BUDVvSe', urlId: window.location.href + '?dogs', headerHTML: '<h1>讨论狗</h1>' }); </script>