Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
change data value in vue component

I'm starting with vue and I'm making a test to change a value when a button is clicked , but is not working

    <template>
  <div class="row">
    {{ show }}
    <div class="col-md-4">
      <button class="btn btn-primary" @click="change_show">Good</button>
    </div>
    <div class="col-md-4">
      <button class="btn btn-primary">Bad</button>
    </div>
    <div class="col-md-4">
      <button class="btn btn-primary">Food</button>
    </div>
  </div>
</template>

<script>
export default {
  name: "buttons",
  data(){
    return{
      show: true
    }
  },
  methods:{
    change_show(event){
      show = !show;
    }
  }
}
</script>

<style scoped>

</style>

I get this error

Uncaught ReferenceError: show is not defined

How I can access to the variables and change it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have declared your variable incorrectly, you should add show (and all your reactive variables) in the return:

data(){
  return{
    show: true
  };
},
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda