Question:
I have achildComponent
which is rendered dynamically via v-for
inside of the parentComponent
. Inside the Parent component I have some logic that fetches data from the database and displays it on the screen. The fetch request query is bases on the child component selected (clicked on). Once the user has clicked on a component I would like to show the user that the data is loading by changing text inside the child component to loading
. The issue I’m facing is that when the request has been sent, all children components generated by v-for
change status to “Loading…”. I would only like the once that has been clicked to change.Edit: Added CodeSandbox
I created a simple representation of my problem.
parentComponent.vue
Answer:
try to pass index asloading
prop instead of boolean:If you have better answer, please add a comment about this, thank you!