我正在尝试理解webix框架,并在我的flask应用程序中使用它。所有文档要么处理html文件中的静态数据,要么处理php示例。
填充datatable的简单html文件如下所示(根据文档
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="../static/css/webix.css" type="text/css" charset="utf-8">
<script src="../static/js/webix.js" type="text/javascript" charset="utf-8"></script>
<title>Webix Test 4</title>
</head>
<body>
<script>
webix.ui({
id:"dtable",
view:"datatable",
url:"/gettabledata"
});
</script>
</body>
</html>在我的flask路由器中,我完成了以下操作(来自教程):
peopleData = {'data':[
{'title': "01. Basique", 'duration': "3:38"},
{'title': "02. Moon", 'duration': "3:47"},
{'title': "03. Unsaid", 'duration': "3:48"},
{'title': "04. Eitheror", 'duration': "5:45"},
{'title': "05. Above the Clouds", 'duration': "3:50"}]}
return jsonify(peopleData)该网页未显示任何内容。
在尝试理解如何使用python和flask加载变量(例如页面标题)时,我遇到了类似的问题。
显然,我遗漏了一些关于webix如何与python/flask一起工作的基本信息。(嵌入数据的页面工作正常,没有问题)
发布于 2016-07-17 19:05:01
首先,您需要在不使用Flask的情况下尝试
index.html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="http://cdn.webix.com/edge/webix.css" type="text/css" charset="utf-8">
<script src="http://cdn.webix.com/edge/webix.js" type="text/javascript" charset="utf-8"></script>
<title>Webix Test 4</title>
</head>
<body>
<script>
webix.ui({
rows: [{
view: "template",
type: "header",
template: "My App!"
}, {
view: "datatable",
autoConfig: true,
editable: true,
data: [
{'title': "01. Basique", 'duration': "3:38"},
{'title': "02. Moon", 'duration': "3:47"},
{'title': "03. Unsaid", 'duration': "3:48"},
{'title': "04. Eitheror", 'duration': "5:45"},
{'title': "05. Above the Clouds", 'duration': "3:50"}]
}]
});
</script>
</body>
</html>python3 -m http.server 9004
jsfiddle
然后用Flask试试
<script>
var my_data = webix.ajax().get("http://localhost:9004/my_route");
webix.ui({
rows: [{
view: "template",
type: "header",
template: "My App!"
}, {
view: "datatable",
autoConfig: true,
editable: true,
data: my_data
}]
});
</script>https://stackoverflow.com/questions/38419927
复制相似问题