layUI treeTable.js:271 Uncaught TypeError: Cannot read property 'children' of undefined

最近用到layUI的treetable,官方给的数据没有问题,

自己改的就GG,总是报 treeTable.js:271 Uncaught TypeError: Cannot read property 'children' of undefined

然后折腾半天,发现第一个参数必须叫做id

我的数据源为 :

data=[{'id': '4.0000000005591e-06',"cost":"545456" ,"children":[{'id': '4.9999999873762e-06',"cost":"4545asdasdd" } ]  } ]

数据源第一参数名必须为id,不然就报错,想显示其他名称可以在渲染表格时改title

 {field: "id1", title:"cost"}

我的就改成了cost

 

你可能感兴趣的:(前端,layui)