Your disabled attribute requires a boolean:
<input :disabled="validated"/>
Notice how I checked only if validated - this should work, since 0 is falsey ... for example
0 is considered to be false in JS (like undefined or null)
1 is in fact considered to be true
To be especially careful, try: <input :disabled="!!validated"/>
This double negation turns falsey or truthy value 0 or 1 to false or true
you do not trust me? go to the console and type !!0 or !!1 :-)
Also, to make sure your numbers 1 or 0 definitely designated as a number, not the string '1' or '0' expect the value you check with + for example, <input :disabled="!!+validated"/> this turns a string of numbers into a number, e.g.
+1 = 1 +'1' = 1 As David Morrow said above, you can put your conditional logic in a method - this gives you more readable code - just return the condition you want to check from the method.
Francis Leigh Dec 28 '17 at 16:26 2017-12-28 16:26
source share