Vue.js bind the :value of a elment on a v-if condition

Viewed 34

Is it possible to bind the :value of a html element on v-if condition like:

<td v-if="isset == true" :value="value1" v-else :value="value2"></td>

So the v-if should only bind the :value not the whole element


I dont need this, this doesnt work for me:

<td v-if="isset == true" :value="value1"></td>

<td v-else :value="value2"></td>
1 Answers

Yes you can just do this:

<td :value="isset == true ? value1 : value2"></td>

Or even better: use a computed property

Related