How does the element-ui tree tree load background data?

?
data () {
return {

data: [{
  label: " 1",
  children: [{
    label: " 1-1",
    children: [{
      label: " 1-1-1"
    }]
  }]
}, {
  label: " 2",
  children: [{
    label: " 2-1",
    children: [{
      label: " 2-1-1"
    }]
  }, {
    label: " 2-2",
    children: [{
      label: " 2-2-1"
    }]
  }]
}, {
  label: " 3",
  children: [{
    label: " 3-1",
    children: [{
      label: " 3-1-1"
    }]
  }, {
    label: " 3-2",
    children: [{
      label: " 3-2-1"
    }]
  }]
}],
defaultProps: {
  children: "children",
  label: "label"
}

};
}
};

topic description

it is also said on the Internet: you have misunderstood, the things given by the background do not need you to loop, and you do not need you to define the content in this array. Let the backend basically return in this format. Let me show you the

I returned.

{

"status": 1,
"message": "",
"data": [{
    "id": 4,
    "parent_id": 0,
    "url": "content",
    "name": "",
    "icon": "el-icon-menu",
    "sort": 100,
    "created_at": "2018-07-05 12:06:27",
    "updated_at": "2018-07-05 14:37:04",
    "deleted_at": null,
    "_child": [{
        "id": 5,
        "parent_id": 4,
        "url": "articles",
        "name": "",
        "icon": null,
        "sort": 100,
        "created_at": "2018-07-05 12:07:29",
        "updated_at": "2018-07-05 14:24:55",
        "deleted_at": null,
        "is_last": true
    }, {
        "id": 6,
        "parent_id": 4,
        "url": "category",
        "name": "",
        "icon": null,
        "sort": 100,
        "created_at": "2018-07-05 14:24:06",
        "updated_at": "2018-07-05 14:25:46",
        "deleted_at": null,
        "is_last": true
    }, {
        "id": 7,
        "parent_id": 4,
        "url": "article_edit",
        "name": "",
        "icon": null,
        "sort": 100,
        "created_at": "2018-07-05 14:26:43",
        "updated_at": "2018-07-05 14:26:43",
        "deleted_at": null,
        "is_last": true
    }],
    "is_last": false
}, {
    "id": 8,
    "parent_id": 0,
    "url": "system",
    "name": "",
    "icon": "el-icon-menu",
    "sort": 100,
    "created_at": "2018-07-05 14:28:09",
    "updated_at": "2018-07-05 14:37:34",
    "deleted_at": null,
    "_child": [{
        "id": 10,
        "parent_id": 8,
        "url": "config",
        "name": "",
        "icon": null,
        "sort": 99,
        "created_at": "2018-07-05 17:02:22",
        "updated_at": "2018-07-05 17:02:22",
        "deleted_at": null,
        "is_last": true
    }, {
        "id": 9,
        "parent_id": 8,
        "url": "menu",
        "name": "",
        "icon": null,
        "sort": 100,
        "created_at": "2018-07-05 14:28:24",
        "updated_at": "2018-07-05 14:28:24",
        "deleted_at": null,
        "is_last": true
    }],
    "is_last": false
}]

}

sources of topics and their own ideas

how do I return the background data to this format, how to understand the background and foreground code, and how to write

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Jun.17,2021

first take a look at the js array, the concept of objects, and then read the element ui tree documentation. Maybe you'll understand a little bit.


returns data, which is the tree structure. Set
defaultProps: {
children:'_ child',
label: 'name'
}
to

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9b514-1848.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9b514-1848.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?