带url的Bootstrap4树视图';s
我试图在Bootstrap4中创建一个可折叠/可扩展的树状视图。有很多这样的例子,但我还没有得到任何需要的工作。问题是,我所能找到的它们中没有一个树中文本的url。我一添加链接,树就不能正常工作了。我发现上面描述的那个最接近。我使用的代码就在这里。这已经被编辑过了。请参阅代码下面的我的评论带url的Bootstrap4树视图';s,url,bootstrap-4,treeview,Url,Bootstrap 4,Treeview,我试图在Bootstrap4中创建一个可折叠/可扩展的树状视图。有很多这样的例子,但我还没有得到任何需要的工作。问题是,我所能找到的它们中没有一个树中文本的url。我一添加链接,树就不能正常工作了。我发现上面描述的那个最接近。我使用的代码就在这里。这已经被编辑过了。请参阅代码下面的我的评论 <!DOCTYPE html> <html> <head> <title>Bootstrap Treeview Exam
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Treeview Example</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="col-sm-4">
<div id="myTree"></div>
</div>
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var treeData = [
{
text: '<a href="google.com">Google</a>',
nodes: [
{
text: "Child-Item-1",
nodes: [
{
text: "Grandchild-Item-1"
},
{
text: "Grandchild-Item-2"
}
]
},
{
text: "Child-Item-2"
}
]
},
{
text: "Parent-Item-2"
},
{
text: "Parent-Item-3"
},
{
text: "Parent-Item-4"
},
{
text: "Parent-Item-5"
}
];
$('#myTree').treeview({
data: treeData
});
});
</script>
</body>
</html>
$tmp_data[$v['id']] = &$v;
}
引导树视图示例
$(文档).ready(函数(){
变量treeData=[
{
文本:“”,
节点:[
{
正文:“子项1”,
节点:[
{
正文:“孙子项目1”
},
{
正文:“孙子项目2”
}
]
},
{
案文:“子项目2”
}
]
},
{
文本:“父项-2”
},
{
文本:“父项-3”
},
{
正文:“父项-4”
},
{
文本:“父项-5”
}
];
$(“#myTree”).treeview({
资料来源:treeData
});
});
$tmp_数据[$v['id']]=&$v;
}
我已经通过示例更改为非php,以便可以看到问题。这是新的。正如你所看到的,折叠/展开工作正常,但是如果你点击谷歌链接,什么也不会发生。任何人都能找到一种方法来实现这一点,或者有更好的方法吗?如果您想放置URL,您需要在treeData数组中添加一个“href”属性,如下所示(确保enableLinks为true):
var treeData=[
{
文字:“谷歌”,
href:'https://www.google.com',
节点:[
{
正文:“子项1”,
节点:[
{
文本:“孙子-Item-1”,
href:'https://www.google.com',
},
{
文本:“孙子-Item-2”,
href:'https://www.google.com',
}
]
},
{
正文:“子项-2”,
href:'https://www.google.com',
}
]
},
{
文本:“父项-2”,
href:'https://www.google.com',
},
{
文本:“父项-3”,
href:'https://www.google.com',
},
{
文本:“父项-4”,
href:'https://www.google.com',
},
{
文本:“父项-5”,
href:'https://www.google.com',
}
];
$(“#默认树”).treeview({
资料来源:treeData,
//扩展到2级
级别:2,
//自定义图标
expandIcon:'字形箭头向下粗体',
拼贴图标:“向上加粗符号箭头”,
emptyIcon:'字形图标',
nodeIcon:“,
选择命令:“”,
checkedIcon:'字形检查',
未选中的选项:“”,
//颜色
颜色:'蓝色',//'#000000',
背景色:未定义,/'#FFFFFF',
边框颜色:未定义,/'#dddddd',
onhoverColor:“#F5”,
所选颜色:“#FFFFFF”,
所选背景色:“#428bca”,
searchResultColor:“#D9534F”,
searchResultBackColor:未定义,/'#FFFFFF',
//启用链接
启用链接:正确,
//突出显示选定项目
highlightSelected:正确,
//突出显示搜索结果
highlightSearchResults:正确,
//显示边界
showBorder:没错,
//显示图标
showIcon:没错,
//显示复选框
showCheckbox:true,
//显示标签
showTags:false,
//启用多选功能
多重选择:错误
});代码>