【发布时间】:2015-01-08 19:34:21
【问题描述】:
我现在正在开发基于flask 的网站,我想使用bootstrap-table 加载一个data.json。但我只得到了没有数据的表格。
目录结构如下图:
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')
“新 .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 %}
我已经链接了 base.html 中所需的所有 css 和 js 文件
但是当 index.py 运行时,我得到的页面如下。只显示表格,不显示数据
有人遇到过这个问题吗?
【问题讨论】:
-
你能告诉我们你用来加载数据的代码吗?
-
@dazedconfused 根据bootstrap-table上的例子,我认为在html中设置'data-url=data1.json'时可以加载数据。是不是错了?
-
似乎是正确的;你的
data1.json是什么样的?它是否包含id、name和price作为其字段?另外,我发现您的new.html中没有包含jquery、bootstrap和bootstrap-table;见Usage -
@dazedconfused data1.json 与example on official website 相同,并且我已链接 base.html 中的所有文件。如表所示,css 工作没有问题,但只有数据丢失。
标签: python html json twitter-bootstrap flask