Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hjortur17's avatar

Help with VUE Watch

So my data is structured like this:

data() {
	booking: {
		name:
		carNumber:
		carSize
	}
}

But what I would like to do is to only watch the carSize data. Is that possible? I'm doing this right now but that is watching all changes made to the booking object

watch: {
        booking: {
			deep: true,
			handler () {
                this.getServices(this.booking.carSize);
			}
		}
    },
0 likes
3 replies
koramit's avatar
koramit
Best Answer
Level 9

You can watch for an attribute in object, like this

watch: {
  'booking.carSize' (val) {
    // do something
  }

and you should return in data ()

data() {
    return {
	  booking: {
		  name:
		  carNumber:
		  carSize
	  }
   }
}

Please or to participate in this conversation.