Vue Answers

What’s difference between v-model and v-bind on Vue.js?

Spread the love

v-model and v-bind are both Vue.js directives, but they serve different purposes:


The v-model directive is primarily used for two-way data binding on form inputs.

It creates a binding between a form input element and a piece of data in the Vue instance.

Changes made to the input value will automatically update the associated data property, and changes to the data property will update the input value.

For example we write

<input v-model="message" type="text">

In this example, message is a data property in the Vue instance, and its value will be synchronized with the value of the input field.


The v-bind directive is used to bind an attribute or a component prop to an expression.

It’s typically used when we want to dynamically bind an attribute or a prop to a value that can change over time. Unlike v-model, v-bind doesn’t establish any two-way data binding.

For instance we write

<div v-bind:class="{ active: isActive }"></div>

In this example, the class attribute of the <div> element will be bound to the value of the isActive data property.

If isActive is true, the active class will be applied; otherwise, it will not.

In conclusion, v-model is specifically for form inputs and creates a two-way data binding between the input value and a data property.

v-bind is used to dynamically bind attributes or props to expressions and doesn’t create any two-way data binding. It’s more general-purpose and can be used with any HTML attribute or Vue component prop.

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 *