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

546
Vistas
(Vuejs) Property or method is not defined on the instance but referenced during render

I have a simple button suppose to add an item in a list:

          <label for="numit">item number:</label>
          <input type="text" id="numit" :value="idxItemBuy">
          <button id="buyitem" @click="buy($event.target.value)">Buy</button>
 buy() {
    console.log("buy fonction")
    this.currentPlayer.buy(this.idxItemBuy)
  }

but it's acctualy not calling the method buy ( and i don't know when i'm suppose to use $event.target.value)

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can read more about v-model => bind input with a data (https://vuejs.org/v2/guide/forms.html or https://v3.vuejs.org/guide/forms.html#text)

I write you a code that works

<template>
  <div>
    <label>item number:</label>
    <input type="text" v-model="idxItemBuy" />
    <button @click="buy">Buy</button>

    <ul>
      <li v-for="item in items" :key="item">
        {{ item }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      idxItemBuy: "",
      items: [],
    };
  },
  methods: {
    buy() {
      console.log("buy fonction", this.idxItemBuy);
      this.items.push(this.idxItemBuy);
    },
  },
};
</script>
over 4 years ago · Santiago Trujillo 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