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

 

發佈了54 篇原創文章 · 獲贊 17 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章