M
M
Max Zhukov2017-10-04 16:08:09
Vue.js
Max Zhukov, 2017-10-04 16:08:09

When clicking on an image, how to get the object of this image in the vue method?

<img v-on:click="chooseImg" class="img_own" style="width:150px; height:150px; border:1px solid silver">

chooseImg:function(e){
            console.log(e);
       }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2017-10-04
@MaksZhukov

"Image object" - in the sense, a DOM element? Well, you can:
@click="onClick"

methods: {
  onClick(e) {
    console.log(e.target);
  }
}

W
wcoder, 2017-10-04
@wcoder

v-on:click="chooseImg($event)"

chooseImg:function(event){
            console.log(event);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question