One option is to put the state of each modal in an object. This way, you don't need to add a data attribute to each modal.
If the content inside the modal is similar enough, you can use v-for, using the index as the key in the same way.
<b-modal v-model="modal_states[1]">模態(tài)框1</b-modal> <b-button @click="openModal(1)">打開1</b-button> <b-modal v-model="modal_states[2]">模態(tài)框2</b-modal> <b-button @click="openModal(2)">打開2</b-button> <b-modal v-model="modal_states[3]">模態(tài)框3</b-modal> <b-button @click="openModal(3)">打開3</b-button>
data: { modal_states: {}, }, methods: { openModal(index){ this.modal_states = {[index.toString()]:true} } },