jstree中json data 的生成
jstree官网上给出的json数据格式是这样的:
<span style="font-size:14px;">// Alternative format of the node (id & parent are required)
{
id : "string" // required
parent : "string" // required
text : "string" // node text
icon : "string" // string for custom
state : {
opened : boolean // is the node open
disabled : boolean // is the node disabled
selected : boolean // is the node selected
},
li_attr : {} // attributes for the generated LI node
a_attr : {} // attributes for the generated A node
}</span>
如果我想要把一个文件夹及它里面的文件用jstree显示,怎么办呢?总不能自己再按上边的格式一个一个写吧。好了,这里就涉及到一个问题,怎么样把一个路径转化成json data.
举个例子:我在E盘下有一个test文件夹,我想要把test文件夹下的所有文件用jstree目录树显示。这时候jstree的数据源就应该是test文件夹的 json数据。
test文件夹下的目录结构如下图:
test文件目录它的json格式应该