Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
How to add specific data to nested children in he-tree-vue javascript library

The following is an example of an array of objects, where the data consists of four levels of nested data.

here I display the children's data on the he-tree-vue when the user presses the toggle on a specific element then makes a request to the api, so later the data is added to a certain array value based on existing data to be displayed as child data.

[{ // class
      ClassID:"0ede11",
      Title:"Mandiri",
      children:[{ // course/subject
            CourseID:"0ec2",
            Title:"Math",
            children:[ // chapter
               {
                  ChapterId:"0ss23",
                  Title:"Test test",
               },
          {
                  ChapterId:"0ss23",
                  Title:"Test test"
               },
          {
                  ChapterId:"0se22",
                  Title:"Test test"
               },
        ]      
      },
      {
            CourseID:"rere43",
            Title:"History",
            children:[
               {
                  ChapterId:"0sse56",
                  Title:"Test test",
               },
          {
                  ChapterId:"0ss2qqq3",
                  Title:"Test test"
               },
          {
                  ChapterId:"0sefg22",
                  Title:"Test test"
               },
        ]      
      }
   ]
}]

how do I add data to specific children, here I use the he-tree-vue library to display a data tree that can be dragged.

now i use the following code, but it only works on the first child only.

getChapter(id, index) {
    this.API.getChapter(id, (data) => {
      console.log(data);
      // I'm still confused in this part, how to dynamically add data to specific child data at each level 
      const newData = [...this.playlistData];
      newData[index].children[index].children = data;
      this.playlistData = newData;
    },
    (err) => {
      console.log(err);
    });
 }

Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Ok solved, I just need to save each index on each level then use it when going to add data.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda