Skip to content

Instantly share code, notes, and snippets.

@gibrandev
Created March 6, 2024 09:53
Show Gist options
  • Save gibrandev/1cb3d46eec48356bda9cbd90f8469c27 to your computer and use it in GitHub Desktop.
Save gibrandev/1cb3d46eec48356bda9cbd90f8469c27 to your computer and use it in GitHub Desktop.
Switch button
<script setup>
const check = reactive({
input: [
true,
false
]
})
const changeCheckbox = (e, i) => {
console.log(e.target.checked);
check.input[i] = e.target.checked
}
</script>
<template>
<div class="p-10" v-for="(item, i) in check.input">
<div>{{ item === true ? 'Yes' : 'No'}}</div>
<input type="checkbox" @change="e => changeCheckbox(e, i)"/> <input :disabled="item" class="disabled:bg-red-900" />
</div>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment