Open nezaboravi opened 4 years ago
What I've done in the past is have some data or prop like "view" that can have either the value "table" or "card". Then, in the parent or wherever you control this piece of state you can toggle the values on a button click. In your component where you actually render the cards or the boxes, just have a v-if="view==='card'" and a second portion v-if="view==='table'" and handle the styling differently.
Edit: One other way to handle it would be to forego having multiple v-ifs and conditionally bind your classes based on that data value. Ex. <div :class="[view === 'card' ? 'w-96 ...' : 'w-full']>
You get the idea.
Thanks @dtparks . Second idea i like more. Will see where it will lead me :) Thanks :)
I am using Vue and Tailwind. Love both. I am wondering how could i achieve following. Currently i am having nice and beautiful page where i am displaying items as card boxes. I have a card component, and items are nicely sorted:
Visitor click on List view and get items on list sorted as list. :D Visitor clicks on Card view and get items sorted in card boxes. Any pseudo code or code example would help. Something like this photo:
Thanks :)
Forgot to add the code :D :D This is my Ads.vue component
And here is my Ad component: