我在php中创建了jsTree视图,问题是显示文件夹图标所有li,我想文件图标文件可用请让我知道正确的解决方案,这是我的代码
<?php
function listFolderFiles($dir){
$ffs = scandir($dir);
echo '<ul>';
foreach($ffs as $ff){
if($ff != '.' && $ff != '..'){
if(!is_dir($dir.'/'.$ff)){
echo '<li><a target="_blank" href="'.SITE_URL.'/'.ltrim($dir.'/'.$ff,'./').'">'.$ff.'</a>';
} else {
echo '<li>'.$ff;
}
if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);
echo '</li>';
}
}
echo '</ul>';
}
?>
//HTML Code
<div id="jstree-ajax"><?php listFolderFiles('../uploads'); ?></div>
//Javascript/JQuery code
<script>
$(document).ready(function() {
$("#jstree-ajax").jstree({
core: {
themes: {
responsive: !1
},
check_callback: !0,
},
types: {
"default": {
icon: "fa fa-folder text-warning fa-lg"
},
file: {
icon: "fa fa-file text-info fa-lg"
}
},
plugins: ["contextmenu", "dnd", "state", "types"]
})
});
</script>
让我知道正确的解决方案
答案 0 :(得分:1)
尝试在引号中包装文件字符串。与jsTree demo
一样"file": {
icon: "fa fa-file text-info fa-lg"
}
json中的其他字符串也应该包含在qotes中