Categories
Vue Answers

How to access a method from another method with Vue.js?

Spread the love

Sometimes, we want to access a method from another method with Vue.js.

In this article, we’ll look at how to access a method from another method with Vue.js.

How to access a method from another method with Vue.js?

To access a method from another method with Vue.js, we use this.

For instance, we write

<script>
export default {
  //...
  methods: {
    methodA() {
      // ...
    },
    methodB() {
      this.methodA();
    },
    //...
  },
};
</script>

to call methodA in methodB by using this.methodA().

Conclusion

To access a method from another method with Vue.js, we use this.

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 *