Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!