bootstrap-treeview 在 bootstrap 4 不兼容解决办法及使用
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 不兼容解决办法及使用的更多相关文章
- IE6/IE7下margin-bottom失效兼容解决办法及双倍边距问题
(从已经死了一次又一次终于挂掉的百度空间人工抢救出来的,发表日期 2014-04-08) 一.IE6/IE7下margin-bottom失效兼容解决办法 1.用padding-bottom代替:2.在 ...
- bootstrap顶部导航遮挡下面内容的解决办法
使用bootstrap设置顶部导航,并将导航栏固定,代码如下: <nav class="navbar navbar-expand-lg navbar-light bg-light fi ...
- 关于Vue.cli 脚手架环境中引入Bootstrap时,table表格样式缺失的解决办法
Vue+bootstrap不能正常使用table的样式 环境:下载官网的本地bootstrap包,然后在vue 的index.html引入bootstrap的css和js环境 问题描述:1. vue里 ...
- IOS中input键盘事件keyup 的兼容解决办法
用input监听键盘keyup事件,在安卓手机浏览器中是可以的,但是在ios手机浏览器中很慢,用输入法输入之后,并未立刻相应keyup事件. 解决办法: 在ios设备上可以用html5的input事件 ...
- js date 火狐不兼容 解决办法 火狐版本25,0
<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...
- Bootstrap之Carousel不能自动播放的解决办法(转)
Bootstrap是一个非常好的css/javaScript框架,尤其对于移动端的自适应和适配能力都比较强. 用Bootstrap自带的Carousel写了一个图片轮播的广告部分,用js调用后却出现了 ...
- bootstrap 下拉菜单不显示的解决办法
bootstrap 下拉菜单不显示,最后改成如下正常显示: <div class="btn-group open"> <ul class="dropdo ...
- bootstrap图标字体不出来问题的解决办法
@font-face { font-family: 'Glyphicons Halflings'; src: url('/Scripts/bootstrap/fonts/glyphicons-half ...
- EXT3.0在IE下Range不兼容解决办法
采用EXT3.0创建一个提示框,IE9下显示异常.经过资料查询,发现添加如下代码即可解决问题. // 这段代码是为了兼容IE if ((typeof Range !== "undefined ...
随机推荐
- [Swift]LeetCode34. 在排序数组中查找元素的第一个和最后一个位置 | Find First and Last Position of Element in Sorted Array
Given an array of integers nums sorted in ascending order, find the starting and ending position of ...
- [Swift]LeetCode633. 平方数之和 | Sum of Square Numbers
Given a non-negative integer c, your task is to decide whether there're two integers a and b such th ...
- React中的通讯组件
1.父传子: 传递:当子组件在父组件中当做标签使用的时候,给当前子组件绑定一个自定义属性,值为需要传递的数据 接收:在子组件内部通过this.props进行接收 2.子传父 传 ...
- JVM基础系列第3讲:到底什么是虚拟机?
我们都知道在 Windows 系统上一个软件包装包是 exe 后缀的,而这个软件包在苹果的 Mac OSX 系统上是无法安装的.类似地,Mac OSX 系统上软件安装包则是 dmg 后缀,同样无法在 ...
- ConcurrentModificationException 异常处理
在工作中碰到有个异常:java.util.ConcurrentModificationException 腾讯bugly工具给出的解决方案和说明如下:该异常表示迭代器迭代过程中,迭代的对象发生了改变, ...
- TypeScript: type alias 与 interface
官方文档中有关于两者对比的信息,隐藏在 TypeScript Handbook 中,见 Interfaces vs. Type Aliases 部分. 但因为这一部分很久没更新了,所以其中描述的内容不 ...
- 基础才是重中之重~Dictionary<K,V>里V的设计决定的性能
回到目录 字典对象Dictionary<K,V>我们经常会用到,而在大数据环境下,字典使用不当可能引起性能问题,严重的可能引起内在的溢出! 字典的值建议为简单类型,反正使用Tuple< ...
- 16-Flink-Redis-Sink
戳更多文章: 1-Flink入门 2-本地环境搭建&构建第一个Flink应用 3-DataSet API 4-DataSteam API 5-集群部署 6-分布式缓存 7-重启策略 8-Fli ...
- Jenkins持续集成01—Jenkins服务搭建和部署
一.介绍Jenkins 1.Jenkins概念 Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,无论用的是什么平台.这是一个免费的源代码,可以处理任何类型的构建或持续集成.集成Je ...
- CentOS 7 镜像文件各个版本区别
CentOS ISO 镜像文件的功能 引导安装 CentOS ISO 镜像文件包含有安装程序,官方称其为 Anaconda,用来引导安装 CentOS 提供 CentOS 的安装文件 镜像文件不一定包 ...