bootstrap-treeview 是bootstrap的一个树形插件,插件依赖:

bootstrap/3.3.7
jquery/3.3.1

经过验证,它不可以在 bootstrap 高于 3.3.7 版本中使用,当前 treeview 的版本为 bootstrap-treeview/1.2.0  ,  bootstrap/3.3.7

<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js"></script>

其实它这个不兼容是因为这个插件用了 版本3 的图标,而 bootstrap 4 却把这些图标给干掉了,因此需要手动添加这些图标文件 Glyphicons.scss:

@charset 'utf-8';

at-root {
// Import the fonts
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../font/bootstrap/glyphicons-halflings-regular.eot');
src: url('../font/bootstrap/glyphicons-halflings-regular.eot') format('embedded-opentype'),
url('../font/bootstrap/glyphicons-halflings-regular.ttf') format('truetype'),
url('../font/bootstrap/glyphicons-halflings-regular.woff') format('woff'),
url('../font/bootstrap/glyphicons-halflings-regular.woff2') format('woff2'),
url('../font/bootstrap/glyphicons-halflings-regular.svg') format('svg');
font-weight: normal;
font-style: normal;
}
} // Catchall baseclass
.glyphicon {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height:;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

bootstrap 3 国内打不开不了,这是个英文版,需要翻墙:https://getbootstrap.com/docs/3.3/getting-started/ 去下载。

在html中,只写一个存放的文件树的容器即可:

<div id="tree"></div>

假定先做一个假数据,使用 tree.json:

[
{
"text":"Bakersfield office",
"nodes": [
{
"text":"Bakersfield BD"
},
{
"text":"Bakersfield marketing"
},
{
"text":"Bakersfield HR"
}
]
},
{
"text":"Stockton office",
"nodes": [
{
"text":"Stockton service"
},
{
"text":"Stockton After sales"
},
{
"text":"Stockton Field service"
},
{
"text":"Stockton Finance"
},
{
"text":"Stockton HR"
}
]
},
{
"text":"Chesapeake office HR"
}
]

然后使用 ajax 将数据填入 #tree 的容器中:

function getTree(){
var url = 'http://127.0.0.1:8020/localhost-cloudClocking-CMS/js/tree.json'; $.ajax({
type:"get",
url:url,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function(data) {
console.log(data);
$('#tree').treeview({
levels: 1,
data:data,
selectedBackColor: 'rgba(#000000,.12)' //这是我本地测试的颜色 可以略过
});
}
});
}

bootstrap-treeview 在 bootstrap 4 不兼容解决办法及使用的更多相关文章

  1. IE6/IE7下margin-bottom失效兼容解决办法及双倍边距问题

    (从已经死了一次又一次终于挂掉的百度空间人工抢救出来的,发表日期 2014-04-08) 一.IE6/IE7下margin-bottom失效兼容解决办法 1.用padding-bottom代替:2.在 ...

  2. bootstrap顶部导航遮挡下面内容的解决办法

    使用bootstrap设置顶部导航,并将导航栏固定,代码如下: <nav class="navbar navbar-expand-lg navbar-light bg-light fi ...

  3. 关于Vue.cli 脚手架环境中引入Bootstrap时,table表格样式缺失的解决办法

    Vue+bootstrap不能正常使用table的样式 环境:下载官网的本地bootstrap包,然后在vue 的index.html引入bootstrap的css和js环境 问题描述:1. vue里 ...

  4. IOS中input键盘事件keyup 的兼容解决办法

    用input监听键盘keyup事件,在安卓手机浏览器中是可以的,但是在ios手机浏览器中很慢,用输入法输入之后,并未立刻相应keyup事件. 解决办法: 在ios设备上可以用html5的input事件 ...

  5. js date 火狐不兼容 解决办法 火狐版本25,0

    <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...

  6. Bootstrap之Carousel不能自动播放的解决办法(转)

    Bootstrap是一个非常好的css/javaScript框架,尤其对于移动端的自适应和适配能力都比较强. 用Bootstrap自带的Carousel写了一个图片轮播的广告部分,用js调用后却出现了 ...

  7. bootstrap 下拉菜单不显示的解决办法

    bootstrap 下拉菜单不显示,最后改成如下正常显示: <div class="btn-group open"> <ul class="dropdo ...

  8. bootstrap图标字体不出来问题的解决办法

    @font-face { font-family: 'Glyphicons Halflings'; src: url('/Scripts/bootstrap/fonts/glyphicons-half ...

  9. EXT3.0在IE下Range不兼容解决办法

    采用EXT3.0创建一个提示框,IE9下显示异常.经过资料查询,发现添加如下代码即可解决问题. // 这段代码是为了兼容IE if ((typeof Range !== "undefined ...

随机推荐

  1. js注入攻击

    注入攻击一般指用户输入数据导致页面乃至整个网站.服务器异常的情况. 直接看一个例子: <html> <head> <title>Test</title> ...

  2. [Swift]LeetCode42. 接雨水 | Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  3. mysql与PHP建立连接实现增删查改

    mysql与PHP连接的查询写法: <?php //1.建立与数据库的连接 //类似于宽字符集问题,mysqli是额外的扩展 //需要找到配置文件去开启扩展 //如果需要在调用函数 之前忽略错误 ...

  4. 好用的函数,assert,random.sample,seaborn tsplot, tensorflow.python.platform flags 等,持续更新

    python 中好用的函数,random.sample等,持续更新 random.sample random.sample的函数原型为:random.sample(sequence, k),从指定序列 ...

  5. vue实例属性的方法

    1.$mount()   手动设置挂载点  eg:vm.$mount("#app") 2.$destroy()  销毁   eg:vm.$destroy(); 3.$forceUp ...

  6. Java面试题:小白不得不懂的斐波那契数列

    很长一段时间里,我都非常疑惑:“我写的技术文章不差啊,有内容的同时还很有趣,不至于每篇只有区区几十个人读啊?为什么有些内容简单到只有一行注册码的文章浏览量反而轻松破万?”这样的疑惑如鲠在喉啊!写技术博 ...

  7. expect--自动批量分发公钥脚本

    1.在使用之前,先安装epel源,yum install expect -y2.写分发脚本,后缀为exp #!/usr/bin/expect set host_ip [lindex $argv 0] ...

  8. C#版 - Leetcode 414. Third Maximum Number题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...

  9. 关于HotSpot VM以及Java语言的动态编译 你可能想知道这些

    目录 1 HotSpot VM的历史 2 HotSpot VM 概述 2.1 编译器 2.2 解释器 2.3 解释型语言 VS 编译型语言 3 动态编译 3.1 什么是动态编译 3.2 HotSpot ...

  10. PyQt:个性化登录界面模仿QQ登录

    写在前面 写了一个登录界面的demo,类似QQ的,写的自己喜欢的样式,贴一下代码,先上效果,如下 陈述 PyQt5+Python3.5.2 login.py是里登录的主界面loginWnd类,Head ...