Skip to content
Advertisement

Why is password validation not working in setup in vuetify?

I am a newbie to vuetify.

To apply password validation, we defined as follows.

JavaScript
JavaScript

When applied as follows, password_show works well, but rules do not apply.

However, as in the code shown as an example, if you subtract it with data() , it works well. What is the reason??

JavaScript

I want to define it all at once inside setup().

Advertisement

Answer

In the vue setup function, unlike in data, you don’t have access to this, so this.$t is undefined in your rules in the setup function:

JavaScript
JavaScript

To access i18n in the setup function you need something like this:

JavaScript

Here’s more on using i18n with the Vue 3 composition api

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement