Answer the question
In order to leave comments, you need to log in
How not to assign a class if the value of the variable is null?
The bottom line is this, I have a form and input fields in it, after the user removes focus from the input field, I need to check it and change the value of the corresponding field in data, for example form.name = false. I will return false if the fields are not filled in correctly, and based on these variables, I need to assign a class, class 2, to an error and to a correct input, but as long as the user has not touched the fields, there should be no classes.
Now I tried to do it like this:
:class="form.FirstName ? 'input-successes' : 'input-error'"
//даже так
v-bind:class="{ 'input-successes': form.FirstName, 'input-error': !form.FirstName, '': form.FirstName === null }"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question