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

245
Views
¿Cómo cambiar la variable de referencia en el componente secundario de @click en el elemento principal? Vista 3

Tengo un componente modal 'ConfirmModal.vue' de TailwindUI que se puede abrir/cerrar configurando 'const open = ref(true/false)'

 <template> <TransitionRoot as="template" :show="open"> <Dialog as="div" class="relative z-10" @close="open = false">

"Abrir" se define en la configuración del componente así

 <script setup> import { ref } from 'vue' const open = ref(false) </script>

Este componente modal se importa al padre 'Edit.vue':

 <script> import ConfirmModal from '@/Components/ConfirmModal.vue'; export default { components: { ConfirmModal },

Idealmente, quiero establecer "abrir" en verdadero cuando el usuario hace clic en el icono de la papelera. Me las arreglé para pasar algunos accesorios al componente, como un mensaje para mostrar, pero me costó entender lo que se requiere en este caso.

 <TrashIcon @click="???"/> <ConfirmModal :title="'Delete client'" :message="'Are you sure you want to delete this client? This action cannot be undone.'"/>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puedes pasar otro accesorio para mostrar/ocultar y verlo:

 const { ref, watch } = Vue const app = Vue.createApp({ setup() { const isActive = ref(false) return { isActive } } }) app.component('modal', { template: ` <div v-show="active"> <h3>{{ title }}</h3> <p>{{ message }}</p> <button @click="active = !active">close</button> </div> `, props: ['open', 'title', 'message'], setup(props) { const active = ref(props.open) watch( () => props.open, () => active.value = true ); return { active } } }) app.mount('#demo')
 <script src="https://unpkg.com/vue@3"></script> <div id="demo"> <button @click="isActive = !isActive">toggle modal</button> <modal :open="isActive" :title="'Delete client'" :message="'Are you sure you want to delete this client? This action cannot be undone.'"/> </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!