Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Question about Vue basic logic: communicating between parents and children and vice versa

I need some help on some Vue (version 2) basic logic concept about communicating between components, I can't seem to grasp..

I have a dashboard (Dashboard.vue) from which I open a popup: <FormXPopup v-show="isVisible">

Inside FormXPopup.vue I have a popup component <Popup> with a content slot.

Popup has a close button that emits 'close' which toggles the isVisible boolean in Dashboard.vue.

In Popup's content slot I've placed a form component: <FormX>

FormX has form validation. And a cancel button which also emits 'close' in Dashboard.vue.

Now I want to clear all validation when closing the popup.

I can easily clear it and then emit 'close' when I click the cancel button from inside FormX.vue.

However when I click the close button which resides in <Popup> I don't know how to clear the form.

Also, Popup is being reused so I'm looking for a flexible solution.

So how do I clear the form (the child) when I close the popup (the parent)?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

There is a difference between v-show and v-if in Vue.js

v-show

When you use v-show, Vue will render FormXPopup and apply display: none; to it until isVisible === true.

This costs more when loading the page, but switching the variable is cheap in performance. This should be used when the variable changes a lot.

v-if

When you use v-if, Vue will not render the component until the condition is true. Once the component is rendered, if the condition goes back to false, the component will be destroyed. Hence, you don't need to clear the form manually.

This solution costs less when rendering the initial page, but it takes more time when the variable changes.

Knowing that, you should use v-if in that situation since isVisible doesn't change that much, and since the popup has a state that needs to be reinitialized every time.

about 4 years ago · Juan Pablo Isaza Report

0

v-show is just style adjust logic.

v-show:falseis to add display: none in this tag's style.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!