[Vuejs]-Show error text if button clicked and input text empty in vue 3 scrupt setup

0👍

You don’t need

<button @click="clicked"></button>

Button is of type="submit"
which means that addMember is invoked only if button is clicked.
Also, i would define another ref, for example

 const error = ref(null)

You can check inside addMember if memberName.value is not empty.
For example

   if(!memberName.value) {
    error.value = true 
    return 
    } 

And then use it for conditional rendering.

Leave a comment