当前位置:Gxlcms > PHP教程 > javascript-Laravel生成jstree的json数据

javascript-Laravel生成jstree的json数据

时间:2021-07-01 10:21:17 帮助过:4人阅读

laravel从数据库中取出来的数据如何封装成jstree能够读取的模型?如果有能给个实例就好了……

$("#tree_4").jstree({
    core: {
        themes: {
            responsive: !1
        },
        check_callback: !0,
        data: {
            url: function (e) {
                return "{{ route('api.deparment') }}"
            },
            data: function (e) {
                return {
                    parent: e.id
                }
            }
        }
    },
    types: {
        "default": {
            icon: "fa fa-folder icon-state-warning icon-lg"
        },
        file: {
            icon: "fa fa-file icon-state-warning icon-lg"
        }
    },
    state: {
        key: "demo3"
    },
    plugins: ["dnd", "state", "types"]
})

回复内容:

laravel从数据库中取出来的数据如何封装成jstree能够读取的模型?如果有能给个实例就好了……

$("#tree_4").jstree({
    core: {
        themes: {
            responsive: !1
        },
        check_callback: !0,
        data: {
            url: function (e) {
                return "{{ route('api.deparment') }}"
            },
            data: function (e) {
                return {
                    parent: e.id
                }
            }
        }
    },
    types: {
        "default": {
            icon: "fa fa-folder icon-state-warning icon-lg"
        },
        file: {
            icon: "fa fa-file icon-state-warning icon-lg"
        }
    },
    state: {
        key: "demo3"
    },
    plugins: ["dnd", "state", "types"]
})

laravel 查询出的结果 直接进行 toJson() 即可

人气教程排行