博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用jstree从后台获取数据在前台进行树状菜单展示(树状菜单 JsTree)
阅读量:4136 次
发布时间:2019-05-25

本文共 848 字,大约阅读时间需要 2 分钟。

1.css和js下载地址:

2.把这几个文件拷贝到项目中

3.页面引用,把css和js引到页面中

然后写个标签,用来存放你的树状菜单:

4.开始写个js,从后台获取数据,然后进行展示;

tzs = {};tzs.index = {    //初始化页面    init: function () {        tzs.index.doCreateTree();    },   //给标签绑定事件   event : function(){   },    doCreateTree : function(){       $.getJSON("/user/queryJsTree",function(rs){           $('#myJstree').jstree({                "core" : {                    "mutiple" : false,                    "check_callback" : true,                    "data" : rs.data                }            });        });        //树节点左键相应函数(监听)       $('#myJstree').on("select_node.jstree",function (node,selected,event) {           //当前点击的对象的id            alert(selected.node.id);        })    }};$(function(){    tzs.index.init();});

5.获取数据的接口写法如下:

注意:返回数据的对象需要有id,parent,text属性,用来区分他们的父亲是谁,我的jstreeVO是这样定义的:

5.页面展示效果如下:

starry.每天进步一点点❤

你可能感兴趣的文章
There is no ~/.bashrc to setup user $PATH
查看>>
Why are there sometimes meaningless do/while and if/else statements in C/C++ macros?
查看>>
Linux Spin lock.
查看>>
Linux, BUG: spinlock recursion on CPU
查看>>
Ubuntu 设置 DNS
查看>>
Ubuntu 设置 dhcpd 不要自动启动
查看>>
Including driver firmware on Linux kernel image
查看>>
can't boot the kernel , if the server side is tftpd32.exe
查看>>
Upstream src code to Android
查看>>
Commit our mod to our own repo server
查看>>
LOCAL_PRELINK_MODULE和prelink-linux-arm.map
查看>>
Simple Guide to use the gdb tool in Android environment
查看>>
Netconsole to capture the log
查看>>
Build GingerBread on 32 bit machine.
查看>>
How to make SD Card world wide writable
查看>>
Detecting Memory Leaks in Kernel
查看>>
Linux initial RAM disk (initrd) overview
查看>>
HOWTO: Booting from SD card using U-Boot
查看>>
HOWTO: Booting from SD card using U-Boot
查看>>
Timestamping Linux kernel printk output in dmesg for fun and profit
查看>>