Skip to content

请求增加 整个站点的总评论数调用 #885

Answered by qwqcode
echs-top asked this question in Q&A
Discussion options

You must be logged in to vote

From ChatGPT:

要将数据输出到 HTML 中,你可以使用 JavaScript 来操作 DOM,并将获取的数据插入到 HTML 元素中。以下是一个简单的例子,假设你有一个 <div> 元素用于显示数据:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>显示数据</title>
</head>
<body>
  <div id="dataContainer"></div>

  <script>
    const siteName = '站点名'; // 替换为实际的站点名
    const url = `https://artalk.xxx.com/api/v2/stats/site_comment?site_name=${encodeURIComponent(siteName)}`;

    fetch(url)
      .then(response => {
        if (!response.ok) {
          throw new Error('Network response was not ok');
        }
        return response.json();
      })
      .then(({ data }) => {
        // …

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by qwqcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
3 participants
Converted from issue

This discussion was converted from issue #811 on May 26, 2024 09:59.