search

Home  >  Q&A  >  body text

(Vuejs) Undefined property or method on instance referenced during rendering

I have a simple button for adding items to 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 the buy method is not actually called (And I don't know when I should use $event.target.value)

P粉216203545P粉216203545231 days ago523

reply all(1)I'll reply

  • P粉827121558

    P粉8271215582024-04-03 15:16:36

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

    I wrote a valid code for you

    
    
    sssccc

    reply
    0
  • Cancelreply