FastComments.com
Here you can edit and run the code snippet from our documentation.
Example Code Snippet "切换页面哈希示例"
<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script> <button id="change-page"></button> <div id="fastcomments-widget"></div> <script> (function fastCommentsMain() { let config = { tenantId: 'demo' }; let instance = window.FastCommentsUI(document.getElementById('fastcomments-widget'), config); let page = '#page-1'; function getNextPage() { if (page === '#page-1') { return '#page-2'; } else { return '#page-1'; } } let button = document.getElementById('change-page'); function nextPage() { page = getNextPage(); button.innerText = 'Go to ' + getNextPage(); window.location.hash = page; let locationString = window.location.toString(); config.url = locationString; // 我们也更新 url,这样通知可以链接回正确的页面 config.urlId = locationString; instance.update(config); } nextPage(); button.addEventListener('click', nextPage); })(); </script>
Result