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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.