vue toggle functionality code example
Example 1: vue toggle boolean on click
// In HTML tag
@click="toggle = !toggle"
// In Vue script
export default {
data() {
return {
toggle: false
}
}
}
Example 2: toggle on-click button vue
<button @click="variable = !variable">
Toggle Value
</button>
<script>
export default {
data () {
return {
variable: false
}
}
}
</script>