vue reference data in methods code example
Example 1: vue lifecycle hooks
<script>
export default {
beforeCreate() {
console.log("beforeCreate")
},
created() {
console.log("created")
},
beforeMount() {
console.log("beforeMount")
},
mounted() {
console.log("mounted")
},
beforeUpdate() {
console.log("beforeUpdate")
},
updated() {
console.log("updated")
},
beforeDestroy() {
console.log("beforeDestroy")
},
destroyed() {
console.log("destroyed")
}
}
</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);
}
}