Doesn't work with data from the server
See original GitHub issueHi, thanks for this tool, it’s amazing. Unfortunately, i have a little problem , It doesn’t work with dynamic data, maybe something i made wrong ? Here is my code
<template>
<tree
ref="tree"
:data="treeData"
/>
</template>
<script>
...
data: () => ({
treeData: []
}),
mounted: function () {
this.getTreeData()
},
methods: {
getTreeData() {
var self = this
axios.get('http://localhost:8082/files')
.then((response) => {
self.treeData = response.data
})
.catch((err) => {
console.log('Error : ' + err)
})
}
...
</script>
Thank you !
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Effective Ways To Fix "Couldn't Open Connection To Server"
Here are some of the most effective ways to fix "Couldn't Open Connection To Server." We also answer some top questions!
Read more >How to fix the problem 'can't connect to server' but the internet ...
Your mobile internet uses your carrier's internet connection, not your ISP's connection. Your ISP may be down, or your router may not be...
Read more >Android mobile data not working? Here are some solutions
You might be facing a cellular data issue. Here are some solutions to restore mobile data. Read Next: Common Android issues and how...
Read more >Android Cellular Data Not Working? 8 Ways to Fix
Start by pulling the SIM card tray out of your phone. Remove the SIM card from the tray, reinsert the card properly, and...
Read more >How to fix iPhone and iPad Cellular Data not working? - Setapp
The article outlines key solutions for the situation when cellular data is not working on your iPhone or iPad.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello, so I understood now.
The “data” prop passed, gets copied to a new object, inside the TreeRoot.vue component (node_modules folder, for backend developers better understanding)
This happens because props are immutable, so to maniputate data, the component copies to internal component “data” key.
After server loading, even computed propertie… the empty array was already copied. Check this by analyzing vue dev tools… the component model key will be empty.
Ok, quick fix. Have the component with a v-if directive
This way, “when you will enable it to show”, it will mount the component again, and props wil be already set, and properly copied!
PS: Very IMPORTANT to use v-if and not v-show!! v-if detaches from virtual dom on toggling, and v-show only changes style to “display: none”
Yeah. You are totally right. I have to copy recieved data to a new object because tree uses a its own structure. I think about adding watchers and get rid of this approach… but I will do it later.
That’s why we have a several approaches: