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

159
Views
¿Cuándo pasa a estar disponible un elemento en dom después de usar vue v-if?

¿Cuándo pasa a estar disponible un elemento en el dom después de usar un vue v-if ? ¿Hubiera pensado que podría hacer un selector de consulta en el elemento después de que v-if se evalúe como verdadero?

En el siguiente código, necesito obtener el elemento .test una vez que se muestra la ventana emergente, pero se muestra como nulo. ¿Cómo lo obtengo?

 new Vue({ el: "#app", data() { return { showPopout: false, }; }, methods: { buttonClick(day) { this.showPopout = true; console.log(document.querySelector('.test')); }, }, });
 <script src="https://unpkg.com/vue@2.6.14/dist/vue.js"></script> <div id='app'> <span @click="buttonClick">show popout</span> <div v-if="showPopout"><span class="test">test</span></div> </div>

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

0

Estará allí después de nextTick

 new Vue({ el: "#app", data() { return { showPopout: false, }; }, methods: { buttonClick(day) { this.showPopout = true; this.$nextTick(() => { console.log(document.querySelector('.test')); }); }, }, });
 <script src="https://unpkg.com/vue@2.6.14/dist/vue.js"></script> <div id='app'> <span @click="buttonClick">show popout</span> <div v-if="showPopout"><span class="test">test</span></div> </div>

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!