computed Computed Properties

Last updated: 2026-10-22

computed Computed Properties

The computed option declares derived values that recalculate and cache when dependencies change — used like plain properties in templates.

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

📝 Syntax

export default {
  data() { return { price: 10, qty: 2 } },
  computed: {
    total() { return this.price * this.qty }
  }
}

⚙️ Arguments

valueAn object whose keys are computed names and values are getters (or get/set pairs)

Returns:Read like a property; cached until dependencies change

▶ Example

Edit the code below and see the live result:

Output:

Shows 'Total: 20' and recalculates on any input change.

💡 Key Points

💡 Tip Prefer computed over methods: it caches while methods re-run every render.
⚠️ Warning No side effects inside getters — that is what watch is for.
ℹ️ Note Use the get/set form for writable computed values such as full name.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q How is it different from methods?
A computed caches by dependency; methods run on every access.
Q Why no parentheses in templates?
A It is read like a property — this.total, not a call.
Q Can it depend on props?
A Yes — deriving from props is the classic pattern.
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%

🙏 帮我们做得更好

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

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