Vue TutorialLesson 10Free preview
Vue Methods
This lesson is part of Vue · All levels
Summary
Method is a function defined within a component and can be called from a template or from other code. Methods are useful for accommodating logic that is too complex to keep templates clean. In the Options API, method accesses data through this, whereas in the Composition API data is accessed through the setup result variable.
Key points
- A method is a function within a component that can be called out of a template.
- In the Options API, data and computed access is through this.
- In the Composition API, methods access data through the setup variable.
- The method is suitable for one-way logic, not cached derivative values.
- Method can accept arguments from the template.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.