VueJS conditionally add an attribute for an element

Try:

<input :required="test ? true : false">

Update: It has changed in Vue 3, see this answer https://stackoverflow.com/a/64598898

Leave a Comment