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

101
Visualizações
Vue creates Component before calculating data

I'm facing a issue with vue. I have created a chart and i can initalize it with data, but when i press one of the check-boxes nothing happens, it happens one step later.

so for example: I press check-box one: Nothing changes. I press check-box two: Data of check-box one gets added I press check-box one: Data of one and two are added ...

I hope someone can help me with this.

Thanks :)

App.vue

<template>
   <div v-if="show"> 
      <div id="Chart">
          <Chart v-bind:chartData="this.chartData"/>                         
      </div>
   </div>
   <div>        
      <checkbox @click="changeGraph">Select Data 1</checkbox>
      <checkbox @click="changeGraph">Select Data 2</checkbox>
    </div>
</template>

export default {
   name: 'App', 
   components: {
       Chart,
   },
   data () {
      return {
         chartData: {};
      }
   },
   methods: {
      changeGraph() {
        // Filling chartData in here
      }
   },
   mounted: {
      // init chartData here
   }
}  



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

0

Instead of @click, use @change

@click="changeGraph"
about 4 years ago · Juan Pablo Isaza Relatório

0

This happens because the object is not reactive to a property that it did not have a priori. For this you can use the set functionality of Vue:

this.$set(object, property, value)

// or

import Vue from 'vue'
Vue.set(object, property, value)

This way the reactivity for that property will work.

You can read more about this here.

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