I want to reorder my child components with a data from api in my parent components. Please take a look at the example below:
Parent component:
<div v-if="data">
<Component_1 />
<Component_2 />
<Component_3 />
<Component_4 />
</div>
I want to render like this with a data from backend and user can be able to send me a data like wordpress to reorder the components every time that he wants:
Parent component after user change the order data from backend:
<div v-if="data">
<Component_4 />
<Component_2 />
<Component_1 />
<Component_3 />
</div>
Do I have a way to make it done ? or It's impossible in vuejs?
I tried to make dynamics components but i can't to sort them or I don't know!
You can loop on the backend response array and use the
:isattribute to render the components in the array's item order.Here is a demo-