Categories
Vue Answers

How to hide a div with Vue.js?

Spread the love

Sometimes, we want to hide a div with Vue.js.

In this article, we’ll look at how to hide a div with Vue.js.

How to hide a div with Vue.js?

To hide a div with Vue.js, we can use the v-if directive.

For instance, we write

<template>
  <div>
    <div v-if="seen" id="hide">
      <p>hide me</p>
    </div>
  </div>
</template>

to show the div only if seen if true by adding v-if="seen" to the div.

Conclusion

To hide a div with Vue.js, we can use the v-if directive.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *