Vue js on click get html5 attribute

Viewed 23141

I am doing a project using vuejs latest version. In this project I want to get html5 attribute associating vue on click event.

my button code is

<a href="javascript:" class="btn btn-info btn-xs" @click="editModal"
                                           data_id="{{$staff->id}}">
          <i class="fa fa-pencil"></i>
</a>

and my js is

var staffModal = new Vue({
el: '#app',
methods: {
    editModal: function(){
        console.log(this.data_id);
    }
}});

In my console I get undefined. How to get right value.

4 Answers

here the link to vue docs. Exactly the right way to emit a value to an eventhandler.

    <button v-on:click="$emit('enlarge-text', 0.1)">
       Enlarge text
    </button>
Related