Using the V-cloak directive in Vue
Posted on: March 03, 2021 by Prince Chukwudire
in this article, you will learn how to use the V-cloak directive in Vue.
In simple terms, the v-cloak
directive is used to hide an element while vue is mounting; it works best with a CSS property.
Here is a basic instance of using the directive:
we first declare a property in our css that makes reference to the cloak:
<style scoped>
[v-cloak] {
display: none;
}
</style>
We then add the v-cloak directive to the intended element.
<template>
<div v-cloak>
<p>Hello there, I am {{ name }}</p>
</div>
</template>
<script>
export default {
data() {
return {
name: "Jane Doe"
};
},
};
</script>
<style scoped>
[v-cloak] {
display: none;
}
</style>
Share on social media
//