想要用el-tree做一个默认选中节点的东西,怎么实现。数据是从后台传的。
数据格式:
"id": "-1",
"text": "顶级节点","icon": null,"state": { "opened": true},"checked": true,"attributes": null,"children": [
{ "id": "1ad7d4d1-0fef-b9ee-44cd-0165a289303e", "text": "节点1", "icon": null, "state": { "selected": false
}, "checked": false, "attributes": null, "children": [treeData: [
{
id: "",
text: "",
children: []
}
],
在
axios.get(url).then(res => { this.treeData[0].id = res.data.id; this.treeData[0].text = res.data.text;** this.treeData[0].children = res.data.children;**
})
数据是这样接收的,希望做到的是能够 this.treeData = res.data;
但是这时候treeData数据格式为object,但el-tree接收的data为array格式。
一只名叫tom的猫
jeck猫
随时随地看视频慕课网APP
相关分类