DEV Community

Cover image for Watch Props in Vue/Nuxt Composition API
Manthankumar Satani
Manthankumar Satani

Posted on

13 4

Watch Props in Vue/Nuxt Composition API

Watch dynamic props inside setup method in Nuxt3 or Vue3 CompositionAPI

<script lang="ts" setup>
import { defineProps, watch } from 'vue'

const prop = defineProps({
  value: { default: '', type: [String, Number] },
})

watch(
  () => prop.value,
  () => {
    console.log('prop value changed', prop.value)
  }
)
</script>

<template>
  <div>{{ value }}</div>
</template>

Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
1doneazy profile image
Eazybright😊😊

Thanks for this. It was really helpful.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay