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

135
Visualizações
vue3 blocks tree does not "reload" when changing the data

I am looking for a organization chart plugin for vue 3 and I have found only this one

https://github.com/megafetis/vue3-blocks-tree

The issue that I have is when changing the ref treeData variable the chart is not loading the new structure.

I want to dynamic load the chart. When fetch the data the chart to loads the new data and display it.

Here is the codesandbox example:

https://codesandbox.io/s/flamboyant-gwen-o8vp9?file=/src/App.vue

When press the Add ... the treeData reference variable should load the new data and the chart to display it ... but it doesn't.

Any ideas ?

Should I reload the component on every fetch ?

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

0

Try to use documented way make treeData reactive.

Replace ref to reactive for treeDate definition. Change parts of treeData on onAddData instead replacing all object.

Full changed example:

import { reactive } from "vue";
import VueBlocksTree from "vue3-blocks-tree";
import "vue3-blocks-tree/dist/vue3-blocks-tree.css";

export default {
  name: "Diagram",
  components: { VueBlocksTree },
  setup() {
    let treeData = reactive({
      label: "root",
      children: [
        { label: "child 1" },
        { label: "child 2" },
        {
          label: "subparent 1",
          children: [
            { label: "subchild 1" },
            {
              label: "subchild 2",
              children: [{ label: "subchild 11" }, { label: "subchild 22" }],
            },
          ],
        },
      ],
    });

    // let treeData = ref({});

    const onAddData = () => {
      Object.assign(treeData, { label: "Test", children: [{ label: "Test 1" }, { label: "Test 2" }] });
    };

    return {
      treeData,
      onAddData,
    };
  },
};

UPD: Change code on onAddData by adding Object.assign.

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