in Vuejs, is it possible to bind a model to a button?

Viewed 68

Just starting to work with Vuejs - is it possible to bind a model to a button like so:

<button class="btn btn-outline-secondary" v-model="pricing" @click="showCountyModal = true">edit</button>

It doesn't appear to. Would the idiomatic pattern be to use:

<button class="btn btn-outline-secondary" @click="willShowCountyModal(pricing)">edit</button>

which does seem to work?

1 Answers

v-model in vuejs is used for two-way binding of data from model to template and template to model used for input field to bind data with model, you cannot add v-model to button, its not correct. So second approach is correct:

<button class="btn btn-outline-secondary" @click="willShowCountyModal(pricing)">edit</button>
Related