Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Learn how to show or hide part of your template based on certain conditions.
Review
v-show hides or shows an HTML element based on the value it is passed. When passed a "true" or a truthy value, the element will show. When passed a "false" or falsey value, the element will be hidden.
You can directly set v-show to true or false:
<div id="app">
<h1 v-show="false">Click Me!</h1> <!-- This element will be hidden -->
</div>
Or pass it a property with a value of true or false:
<div id="app">
<h1 v-show="propertyOnDataObject">Click Me!</h1> <!-- This element will be hidden until the value of "propertyOnDataObject" becomes true -->
</div>
new Vue({
el: '#app',
data: {
propertyOnDataObject: false
}
});
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up