javascript - 为什么我会在 JSON.parse 错误时收到 Unexpected end of JSON input
问题描述
当我使用 运行以下 ejs 代码npm start
时,它显示语法错误。
这是代码。我认为在我的猜测中,错误与箭头(=>)有关。
<% JSON.parse(documents).forEach(document => { %>
<a class="list-group-item list-group-item-action" id="<%= document.Key %>" data-bs-toggle="tab"
href="#list-<%= document.Key %>" role="tab" aria-controls="list-<%= document.Key %>" style="min-width: 200px;"><%= document.Key %></a>
<% }) %>
这是我在浏览器上运行 localhost:3000/ 时显示的确切错误
SyntaxError: /javascript/views/pages/dashboard.ejs:14
12| <div class="list-group" id="list-tab" role="tablist" style="margin-top: 10px;">
13|
>> 14| <% JSON.parse(documents).forEach(document => { %>
15| <a class="list-group-item list-group-item-action" id="<%= document.Key %>" data-bs-toggle="tab"
16| href="#list-<%= document.Key %>" role="tab" aria-controls="list-<%= document.Key %>" style="min-width: 200px;"><%= document.Key %></a>
17| <% }) %>
Unexpected end of JSON input at JSON.parse (<anonymous>)
解决方案
推荐阅读
- python - Airflow 基于自定义类中保存的自定义条件动态创建外部任务传感器
- ios - 如何以编程方式为 AppDelegate 中的所有视图控制器设置状态栏背景颜色?
- python - 使用 BeautifulSoup 在 HTML 中查找特定标签
- reactjs - 反应 setState {} 没有设置变量
- python - 为什么在标记化之前拆分数据帧时 tensorflow 会给出 InvalidArgumentError?
- c - 如何使用 C 获取字符串并按字母顺序排列
- javascript - 使用 XMLHttpRequest 在浏览器中来自 javascript 应用程序的 POST 请求正文在到达服务器时为空
- jquery - 未捕获的 ReferenceError:未定义 Switchery
- gitlab - 基于分支名称在 Gitlab CI 中跳过工作
- entity-framework-core - 抽象类映射派生类型