methods Event Handler Methods

Last updated: 2026-10-22

methods Event Handler Methods

The methods option collects component functions used as event handlers and helpers, called by name from templates.

GroupOptions: State
KindOption
ScopeComponent
Vue Version3.0+
SSR SupportYes

📝 Syntax

export default {
  data() { return { count: 0 } },
  methods: {
    add(n) { this.count += n }
  }
}

⚙️ Arguments

valueAn object of functions; this points to the component instance

Returns:No return convention (returns are not auto-tracked)

▶ Example

Edit the code below and see the live result:

Output:

The buttons add 1 and 5 respectively.

💡 Key Points

⚠️ Warning Avoid arrow functions — they do not bind this to the instance.
💡 Tip Pass the name without parentheses unless you need arguments.
ℹ️ Note Prefer computed for derived values; keep methods for behaviour.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q How do methods and computed split work?
A Cached values → computed; actions and arguments → methods.
Q Why is this sometimes undefined?
A Usually an arrow function or destructuring the method away from the instance.
Q Can one method call another?
A Yes — this.other() shares the instance.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏