<b-card-text class="mb-0"> Success </b-card-text> <b-form-checkbox checked="true" class="custom-control-success" name="check-button" switch @change="changeStatus" /> changeStatus() { this.$swal({ icon: "question", text: "Change Status?", buttonsStyling: false, showCancelButton: true, confirmButtonText: "OK", }).then((result) => { if (result.isConfirmed) { // handle code } }); }, Estoy haciendo una casilla de verificación en vuejs. Cuando hago clic en el estado para cambiar el estado, muestra un swal que dice Change Status . El problema que tengo es: cuando solo presiono estado, aparece un mensaje swal , el estado ha cambiado. Quiero que si presiono Ok el estado cambiará, pero si presiono cancelar se mantendrá igual, gracias
su interruptor no es valor reactivo
marcado por defecto es true correcto, cuando su cambio será false
solo necesitas hacerlo reactivo
ejemplo:
data():{ arr:[{name: "test", status: true}, {name: "test2", status: false}]}
hacerlo reactivo
<table id="example-1"> <tr v-for="item in arr" :key="item.name"> <td>{{ item.name }}</td> <td> <b-form-checkbox checked="item.status" <--- this make it reactive class="custom-control-success" name="check-button" switch @change="changeStatus" /> </td> </tr> </table>