Sometimes, we want to access to data from methods with Vue.js.
In this article, we’ll look at how to access to data from methods with Vue.js.
How to access to data from methods with Vue.js?
To access to data from methods with Vue.js, we can use reactive properties.
For instance, we write
export default {
data() {
return {
questions: [],
sendButtonDisable: false,
};
},
methods: {
postQuestionsContent() {
this.sendButtonDisable = true;
},
},
};
to add the sendButtonDisable
reactive property and set its initial value to false
in the data
method.
Then we add the postQuestionsContent
method that sets the sendButtonDisable
reactive property to true
.
Conclusion
To access to data from methods with Vue.js, we can use reactive properties.