javascript - 引导表卡住“正在加载,请稍候”
问题描述
我正在尝试将 API 中的一些数据插入到带有 bootstrapTable 的表中,但我被困在“正在加载..”我的代码中有什么问题?
非常感谢您的帮助!
<table id="table" data-toggle="table" data-height="460" data-ajax="ajaxRequest" data-search="true"
data-side-pagination="server" data-pagination="true">
<thead>
<tr>
<th data-field="Country" data-sortable="true">Country</th>
<th data-field="CountryCode" data-sortable="true">CountryCode</th>
<th data-field="Confirmed" data-sortable="true">Confirmed</th>
<th data-field="Deaths" data-sortable="true">Deaths</th>
<th data-field="Recovered" data-sortable="true">Recovered</th>
<th data-field="Active" data-sortable="true">Active</th>
<th data-field="Date" data-sortable="true">Date</th>
</tr>
</thead>
<script>
$.get("https://api.covid19api.com/country/italy?from=2020-03-01T00:00:00Z&to=2020-04-01T00:00:00Z", function (data) {
$(function () {
$('#table').bootstrapTable({
data: JSON.parse(data)
});
});
});
我首先添加了这些:
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.css">
<link href="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.5/dist/bootstrap-table.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.5/dist/extensions/export/bootstrap-table-export.min.js"></script>
解决方案
谢谢大家,数据不再是 JSON 字符串,而是 JavaScript 对象......我的错!
$("#table").bootstrapTable({
data: data,
});
推荐阅读
- javascript - 如何在 textarea 中显示断线以及从 JavaScript 获取数据到我的 textarea 内部文本
- reactjs - Recharts - 在工具提示中检索插值 y 值
- reactjs - 使用浅层反应测试 - 无法调用。props() 及其后续函数,因为组件由状态控制
- ruby-on-rails - Rails - 初始化后自动加载路径
- sql-server - SQL Server - 通过重试处理死锁
- react-admin - AutocompleteArrayInput 如何处理 react-admin 中的长选项列表?
- java - 使用 Jackson ObjectMapper 将 POJO 转换为 Dynamo AttributeValues 映射
- javascript - 在 Spotfire Mods 中,作为阅读器的一部分,我可以确定数据视图中发生了什么变化吗?
- javascript - Addin Word:Microsoft 可以为 VB 提供但使用 Office Javascript API 的 Shape 对象是否有替代方法?
- javascript - 通过对象数组过滤,javascript