You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><title>Latest Comments</title></head><body><h1>Latest Comments</h1><ulid="commentsList"></ul><script>// 构造请求的URLconstapiUrl="{你的Artalk地址}/api/v2/stats/latest_comments?site_name=站点名&limit=5";// 发起GET请求fetch(apiUrl).then(response=>{if(!response.ok){thrownewError('Network response was not ok');}returnresponse.json();}).then(data=>{// 处理响应数据constcomments=data.data;constcommentsList=document.getElementById('commentsList');// 遍历评论并添加到页面中comments.forEach(comment=>{constli=document.createElement('li');li.textContent=comment.content;commentsList.appendChild(li);});}).catch(error=>{console.error('There was a problem with the fetch operation:',error);});</script></body></html>
请教下怎么在html文件中调用最新的几条评论,看文档中没写,使用的hugo博客系统,感谢
The text was updated successfully, but these errors were encountered: