[Vuejs]-Is there is a better way to capture erros from Vuetify components?

4👍

Add a ref attribute to the v-text-field component like this:

<v-text-field 
  ref="password-confirmation"
  name="new-user-password-confirmation"
  label="Confirm Password"
  type="password"
  single-line
  required
></v-text-field>

Then you can reference the VueComponent instance of the Vuetify text field component (along with its properties and methods) like so:

methods: {
  registerNewUser() {
    console.log(this.$refs['password-confirmation'].hasError)
  }
}

Here’s documentation on refs.

Leave a comment