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. [Swift]LeetCode456. 132模式 | 132 Pattern

    Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that  ...

  2. 正交矩阵、EVD、SVD

    原文地址:https://www.jianshu.com/p/1004dd342fe2 一.正交矩阵 二.EVD 特征值分解(Eigen Value Decomposition, EVD). 对于对称 ...

  3. 优化之Normalizer组件

    Normalizer会产生记录,尽可能的将Normalizer组件靠近Target ---------------------------------------------------------- ...

  4. pytthon—day8 读写模式的结合、文件操作模式、with完成文本文件复制、游标操作

    一.读写模式的结合 w:写指没有新建文件,有文件就清空 w=open('1.txt','w',encoding='utf-8') w.write('000\n') 在写入数据时,需要及时处理内存空间, ...

  5. Cassandra如何利用线性一致性来实现轻量级的事务

    分布式数据库会面临着一个独特的挑战,就是数据必须要严格的按照读,写顺序执行.如创建用户,转账,两个潜在的写操作竞态条件必须要确保一个写操作必须在另外一个之前发生.在Cassandra中,使用Paxos ...

  6. Python爬虫入门教程 3-100 美空网数据爬取

    美空网数据----简介 从今天开始,我们尝试用2篇博客的内容量,搞定一个网站叫做"美空网"网址为:http://www.moko.cc/, 这个网站我分析了一下,我们要爬取的图片在 ...

  7. 数据结构之哈希(hash)表

    最近看PHP数组底层结构,用到了哈希表,所以还是老老实实回去看结构,在这里去总结一下. 1.哈希表的定义 这里先说一下哈希(hash)表的定义:哈希表是一种根据关键码去寻找值的数据映射结构,该结构通过 ...

  8. Android事件机制之二:onTouch详解

    <Android事件机制之一:事件传递和消费>一文总结了Android中的事件传递和消费机制. 在其中对OntachEvent中的总结中,不是很具体.本文将主要对onTach进行总结. o ...

  9. -1-4 java io java流 常用流 分类 File类 文件 字节流 字符流 缓冲流 内存操作流 合并序列流

      File类 •文件和目录路径名的抽象表示形式 构造方法 •public File(String pathname) •public File(String parent,Stringchild) ...

  10. sed从入门到深入的使用心得

    本人已经此系列的sed文章整理到pdf中,欢迎下载:玩透sed:探究sed原理 sed系列文章: sed修炼系列(一):花拳绣腿之入门篇sed修炼系列(二):武功心法(info sed翻译+注解)se ...