[Vuejs]-Render component in vue based on condition

0👍

Here is some sample code to help you.

Check out the code in action here: Vue SFC Playground

"Yes, you are the admin" will only show if the email is admin@gmail.com

<template>
  <div>
    E-mail:
    <span>
      {{email}}
    </span>
  </div>
  <div>
    Are you admin? <span v-show="email == 'admin@gmail.com'">Yes, you are the admin</span>
  </div>
  <input v-model="email" >
</template>

<script>
import { defineComponent } from "vue";
export default defineComponent({
  data() {
    return {
      email: "admin@gmail.com"
    }
  }
});
</script>

Leave a comment