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]LeetCode97. 交错字符串 | Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Input: s1 = ...
- [Swift]LeetCode132. 分割回文串 II | Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...
- [Swift]LeetCode998. 最大二叉树 II | Maximum Binary Tree II
We are given the root node of a maximum tree: a tree where every node has a value greater than any o ...
- [Swift]LeetCode1016. 子串能表示从 1 到 N 数字的二进制串 | Binary String With Substrings Representing 1 To N
Given a binary string S (a string consisting only of '0' and '1's) and a positive integer N, return ...
- VSCode与Deepin资源管理器冲突
解决方式: xdg-mime default dde-file-manager.desktop inode/directory 此外,网上有较多推荐(在deepin 15.8版本上测试无效): gvf ...
- WebSocket(2)---实现游戏公告功能
实现游戏公告功能 实现功能:游戏管理里发布游戏公告,其它游戏玩家页面能够马上接受到游戏公告信息. 下面直接上代码案例,这里主要展示关键代码,底部有源码. 一.案例 1.pom.xml文件 主要是添加s ...
- Spring Boot OAuth 2.0 客户端
在上一篇<OAuth 2.0 授权码请求>中我们已经可以获取到access_token了,本节将使用客户端来访问远程资源 配置资源服务器 授权服务器负责生成并发放访问令牌(access_t ...
- 《HelloGitHub月刊》第 08 期
<HelloGitHub>第 08 期 兴趣是最好的老师,<HelloGitHub>就是帮你找到兴趣! 简介 最开始我只是想把自己在浏览GitHub过程中,发现的有意思.高质量 ...
- ThreadPoolExecutor系列一——ThreadPoolExecutor 机制
ThreadPoolExecutor 机制 本文系作者原创,转载请注明出处:http://www.cnblogs.com/further-further-further/p/7681529.html ...
- 从设计模式的角度看Java程序优化
一.前言 Java程序优化有很多种渠道,比如jvm优化.数据库优化等等,但都是亡羊补牢的措施,如果能在设计程序架构时利用设计模式就把程序的短板解决,就能使程序更加健壮切容易维护迭代 二.常用的设计模式 ...