Categories
Vue Answers

How to access to data from methods with Vue.js?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *