vuejs
/

Vue Data Binding

Last Sync: Today

On this page

10
0%
5 min read
Remaining
5 minleft

Click any section to jump — progress syncs automatically

vuejs

Vue Data Binding

What is Data Binding?

Data binding in Vue connects the data model with the UI, ensuring that changes in data automatically update the view.

One-Way Data Binding

Data flows from the model to the view. When data changes, the UI updates automatically.

HTMLRead-only
1
<p>{{ message }}</p>
<img :src="imageUrl">

v-bind Directive

The v-bind directive dynamically binds HTML attributes to data.

HTMLRead-only
1
<a v-bind:href="url">Visit</a>
<!-- Shorthand -->
<a :href="url">Visit</a>

Two-Way Data Binding

Two-way binding allows data to flow between the model and the view, updating both automatically.

v-model Directive

HTMLRead-only
1
<input v-model="name">
<p>{{ name }}</p>

Binding Types

TypeDirectiveDescription
Text{{ }}Display data
Attributev-bindBind attributes
Two-wayv-modelSync input and data

Event Binding (Related)

HTMLRead-only
1
<button @click="count++">Click</button>

Best Practices

  • Use v-model for forms
  • Use v-bind for dynamic attributes
  • Keep data simple and reactive
  • Avoid unnecessary two-way binding

Common Mistakes

  • Using v-model on non-input elements incorrectly
  • Overusing two-way binding
  • Not understanding reactivity
  • Mixing logic inside templates

Conclusion

Vue data binding simplifies UI updates by syncing data and the DOM efficiently, making applications reactive and dynamic.

Try it yourself

<input v-model="name">
<p>{{ name }}</p>

Test Your Knowledge

Q1
of 3

Which is two-way binding?

A
v-bind
B
v-if
C
v-model
D
v-for
Q2
of 3

What binds attributes?

A
v-model
B
v-bind
C
v-on
D
v-if
Q3
of 3

What displays data?

A
{{ }}
B
v-for
C
v-if
D
v-on

Frequently Asked Questions

What is v-model?

It provides two-way data binding between input and data.

What is v-bind?

It binds HTML attributes dynamically.

What is one-way binding?

Data flows from model to view only.

Previous

vue template syntax

Next

vue interpolation

Related Content

Need help?

Explore our comprehensive docs or start a chat with our tech experts.