add methods vue 2 code example
Example 1: vue methods
<template>
<div id="example">
<button v-on:click="greet">Greet</button>
</div>
</template>
<script>
export default {
methods: {
greet: function(event) {
alert(event.target.tagName);
}
}
};
</script>
Example 2: vue js access data in method
data: function () {
return {
questions: [],
sendButtonDisable : false
}
},
methods: {
postQuestionsContent : function() {
this.sendButtonDisable = true;
var vm = this;
setTimeout(function() {
vm.sendButtonDisable = true;
}, 1000);
}
}