Categories
Vue Answers

How to fire an event when v-model changes with Vue.js?

Spread the love

Sometimes, we want to fire an event when v-model changes with Vue.js.

In this article, we’ll look at how to fire an event when v-model changes with Vue.js.

How to fire an event when v-model changes with Vue.js?

To fire an event when v-model changes with Vue.js, we an listen for the change event.

For instance, we write

<template>
  <input
    type="radio"
    name="optionsRadios"
    id="optionsRadios2"
    value=""
    v-model="srStatus"
    @change="foo"
  />
</template>

to listen for the change event with @change.

If the event is emitted, then we run the foo method.

Conclusion

To fire an event when v-model changes with Vue.js, we an listen for the change event.

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 *