How to Get Data Attribute Value in Vue JS?

By Hardik Savani July 7, 2023 Category : Vue.JS

If you need to get attribute value on click event in vue js then i can help you to getting data attribute value in vuejs. we will write button click event and get custom attribute value in vue.js.

In this example we will take on button with custom attribute like "data-id" and on click event of button we will get that value of custom data attribute value in console. we will get data attribute value using

You can see bellow syntax:;


<!DOCTYPE html>



<title>How to get data attribute value in Vue JS? -</title>

<script src=""></script>



<div id="app">

<button v-on:click="callFunction" data-id="22">Click Me</button>



<script type="text/javascript">

new Vue({

el: '#app',

data: {

message:"Welcome, Please Wait...."



callFunction: function (event) {

var id ='data-id');









I hope it can help you...

Tags :