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

element is the following data format, but all the data returned in the background are nested at the object format level. How do you loop in this?

export default {

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"
    }
  };
 }
};

you misunderstand. 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.
  

you can ask your background to give you a tree-structured data, which I have used recently, but we do not have tree-structured data, all are pieces of data, each with a parent id and its own id, recursively stuffing the parent id equal to id data under his child, that is, in the foreground we assemble the tree data and transmit it to the tree component. Your problem description is not very clear, can you describe it in detail according to your business?

Menu