【发布时间】:2021-06-06 13:43:07
【问题描述】:
我正在尝试显示我在 html 文件中获取的数据。我希望 json 显示在我放置 HERE 的位置,但我不知道如何
<script defer>
fetch("http://localhost:8080/bot/guilds")
.then(data => data.json())
.then((json) => {
document.getElementById("servers").innerHTML = json
})
</script>
<div class="statistics">
<div class="cards">
<div class="card statistic" style="width: 18rem;">
<div class="card-body">
<p class="card-title" style="font-size: 50px !important;line-height: 15px !important;letter-spacing: -0.06em !important;font-weight: bold !important;">HERE</h1>
<p style="font-weight: bold !important;font-size: 20px !important;">servers</p>
</div>
</div>
【问题讨论】:
-
您正在尝试将 HTML 值设置为 JSON?
-
您希望将 JSON 数据简单地显示为
key=value对吗? JSON 有多复杂? JSON中有多少层?到目前为止,还很少有人知道其意图是什么 -
花一点时间在帮助中,您将了解如何将代码复制/粘贴到问题中并正确格式化