Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
(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)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

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>
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!