Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
Vue.js3 Toggle v-show on checkbox/toggle click, how to make v-show reactive on each click
<template>
  <ToggleSwitch class="right "  @onChange.preventDefault="onChange" ></ToggleSwitch>
                        
  <div v-show="!hidden">
    <CheckBox v-if="typeof cellProps.rowData.BrandTypeId === 'boolean'" 
              class="right space" />
    <Input v-if="typeof cellProps.rowData.BrandTypeId != 'boolean'"
           class="right space"
           label="Change Colors" />
  </div>
</template>

<script lang="ts" setup>
    let hidden = true

    const onChange = () => {
        console.log("toggle successful", hidden)
        hidden = !hidden; 
    }
</script>

The hidden value works at render and does not show the checkbox and input in the div. On clicking the the "hidden" value does change, but the v-show does not change. How is this set up incorrectly?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can make your variable reactive with ref :

import { ref } from "vue'
let hidden = ref(true)

const onChange = () => {
    console.log("toggle successful", hidden)
    hidden.value = !hidden.value; 
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda