jeudi 25 août 2022

v-checkbox is selected by default after second call to service

I have an issue and any help will be appreciated I have this loop with checkboxes

<div v-for="(check, i) in alarms" :key="check.value">
  <v-checkbox
    v-if="check.contenido"
    v-model="checksModels[i]"
    :label="'Baja ' + check.contenido"
    :value="check"
  />
</div>

and the function that fetch the elements is this one

async fetchAlarms () {
    this.loading = true
    const alarmsAuhors = this.$axios.$get(`/service/getalarms/5`)
    const alarmsThemes = this.$axios.$get(`/service/getalarms/6`)
    const [resAuthors, resThemes] = await Promise.all([alarmsAuhors, alarmsThemes])
    this.alarms = [...resAuthors, ...resThemes]
    this.tipo5 = Boolean(resAuthors.length)
    this.tipo6 = Boolean(resThemes.length)
    this.loading = false
},

in the data I have both variables

  data: () => ({
    checksModels: [],
    alarms: [],
  }),

alarms fetch the results of the axios calls (everything is normal) the first time. But if I launch the fetchAlarms () for the second time the checkboxes are checked even when the checksModels where I save the selected elements is empty. Anyone knows how can I uncheck them. Thanks in advance

enter image description here




Aucun commentaire:

Enregistrer un commentaire