Conditional rendering with Vue v-if

Conditionals are a core part of programming languages. The vue framework uses the v-if directive amongst others in handling this. The Vue v-if directive renders…

The post Conditional rendering with Vue v-if appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Prince Chukwudire

Conditionals are a core part of programming languages. The vue framework uses the v-if directive amongst others in handling this.

The Vue v-if directive renders a block of code if its directive is truthy.

<template>
  <div>
    <p v-if="isActive">I am actually Active</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isActive: true
    };
  }
};
</script>

As long as the expression isActive remains truthy, our block keeps displaying. The reverse is the case when it is false.

The post Conditional rendering with Vue v-if appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Prince Chukwudire


Print Share Comment Cite Upload Translate Updates
APA

Prince Chukwudire | Sciencx (2021-02-17T16:48:34+00:00) Conditional rendering with Vue v-if. Retrieved from https://www.scien.cx/2021/02/17/conditional-rendering-with-vue-v-if/

MLA
" » Conditional rendering with Vue v-if." Prince Chukwudire | Sciencx - Wednesday February 17, 2021, https://www.scien.cx/2021/02/17/conditional-rendering-with-vue-v-if/
HARVARD
Prince Chukwudire | Sciencx Wednesday February 17, 2021 » Conditional rendering with Vue v-if., viewed ,<https://www.scien.cx/2021/02/17/conditional-rendering-with-vue-v-if/>
VANCOUVER
Prince Chukwudire | Sciencx - » Conditional rendering with Vue v-if. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/17/conditional-rendering-with-vue-v-if/
CHICAGO
" » Conditional rendering with Vue v-if." Prince Chukwudire | Sciencx - Accessed . https://www.scien.cx/2021/02/17/conditional-rendering-with-vue-v-if/
IEEE
" » Conditional rendering with Vue v-if." Prince Chukwudire | Sciencx [Online]. Available: https://www.scien.cx/2021/02/17/conditional-rendering-with-vue-v-if/. [Accessed: ]
rf:citation
» Conditional rendering with Vue v-if | Prince Chukwudire | Sciencx | https://www.scien.cx/2021/02/17/conditional-rendering-with-vue-v-if/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.