Skip to content
Advertisement

Flip Card Component in VueJs 3

I want to achieve a Flip card component like the one here by developing a generic Vue Component, but I’m confused about how can I assign a whole face component (front/back) as a back or front face of the card, and how can I lock the flipping property (as an option), an example of the face (front/back) is:

JavaScript

Can you please tell me how can I achieve that properly? thanks in advance.

The FlipCard.vue Vue component I have tried to develop:

JavaScript

Style.css

JavaScript

Advertisement

Answer

Your card face looks good to put into a new component and then flipCard.vue can display that component, front or back, as a dynamic component

flipCard.vue

JavaScript
JavaScript

more detailed codesandbox here.

Another option is to use slots to display dynamic component content.

Parent component

JavaScript

flipCard.vue

JavaScript

another more detailed codesandbox

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement