Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Vue.js Quick Start Guide

You're reading from   Vue.js Quick Start Guide Learn how to build amazing and complex reactive web applications easily using Vue.js

Arrow left icon
Product type Paperback
Published in Oct 2018
Publisher Packt
ISBN-13 9781789344103
Length 186 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ajdin Imsirovic Ajdin Imsirovic
Author Profile Icon Ajdin Imsirovic
Ajdin Imsirovic
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Introducing Vue 2. Basic Concepts of Vue 2 FREE CHAPTER 3. Working with Vue-CLI, Components, Props, and Slots 4. Filters and Mixins 5. Making Your Own Directives and Plugins 6. Transitions and Animations 7. Using Vuex 8. Using Nuxt.js and Vue-Router 9. Other Books You May Enjoy

Watchers in Vue

Every component in Vue has a watcher. 

To understand how this works, let's begin with an earlier example from this chapter. The example is from the Computed properties section, at this link: https://codepen.io/AjdinImsirovic/pen/qKVyry. That is our starting code. As we know from the previous section, we have two input fields here and we are printing out the values entered into these input fields in some span tags under the form.

Let's extend our example. The initial code is the same; we will only be adding a watcher to it. The updated code can be found at this Codepen URL: https://codepen.io/AjdinImsirovic/pen/jprwKe.

As can be observed, the only update we made to the original pen is the addition of the watchers option, as follows:

  watch: {
ownerName(previousValue,currentValue) {
console.log(`The value in the first input has changed...
You have been reading a chapter from
Vue.js Quick Start Guide
Published in: Oct 2018
Publisher: Packt
ISBN-13: 9781789344103
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime