Frontend/Vue 2

vue3 v-if / v-else-if / v-else

SOLYI 2021. 10. 18. 16:50
<template>
  <button @click="handler">
    click me!
  </button>
  <h1 v-if="isShow">
    Hello!!!! 
  </h1>
  <h1 v-else-if=" count > 3">
    Count > 3
  </h1> 
  <h1 v-else>
    Good~~!
  </h1>
</template>

<script>
export default {
  data(){
    return{
      isShow: true,
      count: 0
    }
  },
  methods:{
    handler(){
      this.isShow = !this.isShow
      this.count += 1
    }
  }
}
</script>
반응형