layuiExtend icon indicating copy to clipboard operation
layuiExtend copied to clipboard

关于后台返回数据解析问题

Open shnno13 opened this issue 6 years ago • 3 comments

后台返回数据:

{
    "code": 0,
    "data": {
        "aggs": [
            {
                "id": 1,
                "text": "A 马克思主义、列宁主义、毛泽东思想、邓小平理论(18)",
                "count": 18
            },
            {
                "id": 7600,
                "text": "K 历史、地理(6)",
                "count": 6
            }
        ],
        "result": null,
        "count": 0
    },
    "currentTime": 1571473510505,
    "msg": "请求成功",
    "traceId": "1185471941461483520",
    "count": 0
}

eleTree定义:

eleTree.render({
	elem: "#categoryList",
	url: baseUrl + "/opac/search/m?st=b&categoryId=0",
	method: "GET",
	emptText: "中图法数据为空",
	lazy: true,
	showLine: true,
	load: function(d, callback) {
		$.get(baseUrl + "/bibliography/category/parent?pid=" + d.id, function(res) {
			callback(res.data)
		})
	},
	request: {
		name: "text",
		key: "id",
		isLeaf: "isLeaf"
	},
	response:{
		dataName: "data.aggs"
	}
});

问题描述

1.当前数据尝试将 dataName修改为data或者data.aggs都不能正确渲染数据 2.showLine无作用

layui 2.5.4 / eleTree(最近修改时间: 2019/05/20)

望李先生解惑,谢谢。

shnno13 avatar Oct 19 '19 08:10 shnno13

在下查看源代码发现,先生您没有对复杂对象做循环处理

shnno13 avatar Oct 19 '19 08:10 shnno13

@Fool-Joker 谢谢你的反馈,以前确实没有对这种做处理,现在已经增加了

hsiangleev avatar Oct 21 '19 03:10 hsiangleev

如果在下没有看错的话,文档中的部分事件没有增加对应代码,还希望先生您在文档加以对应注释。

shnno13 avatar Oct 21 '19 03:10 shnno13