[Vuejs]-How can I add condition that required or not in select vue.js 2?

4👍

You can bind data to plain HTML attributes. It doesn’t need to be a component property.

<select class="form-control" :required="type == 2" ...></select>

Doing this, the select element will only have the required attribute if type == 2.

Leave a comment