[Vuejs]-How to the Clicked image ID in Vuejs

0👍

v-on:click="select($event, kudo.id)"

If your kudo indeed has an id, then this will work. And you need to modify select to take in said id.

0👍

Your select method has to have kudo.id as parameter.

<template>
  <div v-for="kudo in catkudo"  style="width:20%;float:left;display:block;height:80px;">
    <div class="kudos_img" style="">
       <img style="width:40%" :value="kudo.id" @click="select(kudo.id)" v-model="kudocat" :src="'/kudosuploads/badges/'+kudo.image" alt="">
       <p>{{ kudo.catname }}</p>
    </div>
  </div>
</template>
export default {
  methods: {
    select (id) {
      console.log(id, 'is selected');
    }
  }
}

Leave a comment