Python &引用;未找到匹配的记录";在烧瓶中使用引导表时
我现在正在基于flask开发网站,我想使用bootstrap表加载data.json。但我只得到了没有数据的表格 目录结构显示如下:Python &引用;未找到匹配的记录";在烧瓶中使用引导表时,python,html,json,twitter-bootstrap,flask,Python,Html,Json,Twitter Bootstrap,Flask,我现在正在基于flask开发网站,我想使用bootstrap表加载data.json。但我只得到了没有数据的表格 目录结构显示如下: index.py templates/ new.html data.json data1.json static/ css/ bootstrap-table.css bootstrap-theme.css bootstrap-theme.min.css bo
index.py
templates/
new.html
data.json
data1.json
static/
css/
bootstrap-table.css
bootstrap-theme.css
bootstrap-theme.min.css
bootstrap.css.map
base.css
bootstrap-table.min.css
bootstrap-theme.css.map
bootstrap.css
bootstrap.min.css
js/
bootstrap-table.js
bootstrap.js
bower_components/
jquery.min.js
bootstrap-table.min.js
bootstrap.min.js
index.js
npm.js
index.py如下所示:
62 @app.route("/")
63 def new():
64 return render_template('new.html')
<!doctype html>
{% extends 'base.html' %}
{% block title %}Config{% endblock %}
{% block head %}
{{ super() }}
<!--<script type="text/javascript" src='../static/js/index.js'></script> -->
{% endblock %}
{% block header %}
<p class="title">test</p>
{% endblock %}
{% block content %}
<table data-toggle="table" data-url="data1.json" data-cache="false" data-height="299">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
{% endblock %}
“new.html”如下所示:
62 @app.route("/")
63 def new():
64 return render_template('new.html')
<!doctype html>
{% extends 'base.html' %}
{% block title %}Config{% endblock %}
{% block head %}
{{ super() }}
<!--<script type="text/javascript" src='../static/js/index.js'></script> -->
{% endblock %}
{% block header %}
<p class="title">test</p>
{% endblock %}
{% block content %}
<table data-toggle="table" data-url="data1.json" data-cache="false" data-height="299">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
{% endblock %}
{%extends'base.html%}
{%block title%}配置{%endblock%}
{%block head%}
{{super()}}
{%endblock%}
{%块头%}
测试
{%endblock%}
{%block content%}
项目ID
项目名称
项目价格
{%endblock%}
我已经链接了base.html中所需的所有css和js文件
但是当index.py运行时,我得到了如下页面。它只显示表格,但不显示数据
有人遇到过这个问题吗 首先,就Flask而言,确保json文件位于静态文件夹中。这件事太琐碎了,我已经试过很多次了 然后,确保包含json数组的json文件格式正确 FYR
你能告诉我们你用来加载数据的代码吗?@DazedMiddle根据上的示例,我认为在html中设置“data url=data1.json”时可以加载数据。不正确吗?似乎是正确的;你的
data1.json
看起来像什么?它是否包含id
、name
和price
作为其字段?另外,我发现您没有在new.html
中包含jquery
、bootstrap
和bootstrap表
;请参阅@dazedMiddle data1.json与相同,并且我已经链接了base.html中的所有文件。如表所示,css工作正常,但只缺少数据。