[Vuejs]-How can the default value for props be defined in Vue 3?

3👍

Adding a Default Value using withDefaults in the Vue 3 Composition API:

interface InputProps {
  message: string
  error?: string
}

const props = withDefaults(defineProps<InputProps>(), {
  message: null
})

learn more here

Leave a comment