vuejs toggle code example
Example 1: vue v-show toggle
<div v-show="isVisible">
<h1>Título</h1>
<p>Parágrafo 1</p>
<p>Parágrafo 2</p>
</div>
//div will be rendered and toggle display: none; as isVisible is set true or false.
<script>
export default {
data () {
return {
isVisible: false
}
}
}
</script>
Example 2: toggle on-click button vue
<button @click="variable = !variable">
Toggle Value
</button>
<script>
export default {
data () {
return {
variable: false
}
}
}
</script>