Component
<template lang="html">
<div>
<ul>
<li @click="GetUser(this);" v-for="chatuser in chatusers" v-bind:data_id="chatuser.User_ID">
</li>
</ul>
</div>
</template>
<script>
export default {
methods: {
GetUser(id) {
debugger;
var data_id = $(id)[0].attr("data-id");
}
}
}
</script>
<style>
</style>
Problem
In the Li, on click event, there is a function GetUser() with this argument passed. This element has data-id attribute which I am trying to retrieve in the function.
Problem is that, the data_id variable in the function is always undefined and when I debug the js code, it shows id value = Window.
Am I missing anything?
thisin the template will refer to the Window no matter what. try@click='GetUser(chatuser.User_ID)'(and putting the click event after thev-forloop is started)