twitter-bootstrap-3 - 引导树视图:树未显示
问题描述
我是 Bootstrap-treeview (bootstrap-treeview.js v1.0.2) 的新手。我正在尝试显示文档中给出的树,但它没有显示出来。
我检查了两个文件,没有发现错误。
html:
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'bootstrap-treeview.min.css' %}">
<title>test</title>
</head>
<body>
<div class="container">
<div id="tree"></div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" integrity="sha256-ivk71nXhz9nsyFDoYoGf2sbjrR9ddh+XDkCcfZxjvcM=" crossorigin="anonymous"></script>
<script src="{% static 'bootstrap-treeview.min.js' %}"></script>
<script src="{% static 'functions.js' %}"></script>
</body>
</html>
函数.js
function getTree() {
var tree = [
{
text: "Parent 1",
nodes: [
{
text: "Child 1",
nodes: [
{
text: "Grandchild 1",
},
{
text: "Grandchild 2",
}
]
},
{
text: "Child 2",
}
]
},
{
text: "Parent 2",
}
];
return tree;
}
$('#tree').treeview({data: getTree()});
解决方案
您正在创建数组tree
,但data
在getTree
函数中返回
推荐阅读
- django - Django imagefield 不显示在模板上
- ruby-on-rails - 在不同的类别中显示相同的任务
- c++ - 具有默认值的 const 引用参数
- react-native - React Native:如何在覆盖视图中响应事件,然后将事件传递到下一层视图
- visual-studio-code - Visual Studio Code - 空白窗口无边框
- jestjs - 为什么我使用玩笑得到未知选项“extensionsToTreatAsEsm”
- python-sphinx - 尝试创建 DOCX 时出现 Sphinx/PlantUML 错误
- javascript - 无法更改媒体查询
- python - xgboost 给出 inf 或 nan 错误,但训练数据中没有无限值
- r - 在 R 中创建一个“生存”假人(面板数据)