Skip to content

Instantly share code, notes, and snippets.

@kapillamba4
Created August 24, 2018 19:21
Show Gist options
  • Save kapillamba4/a22093a1b4c3032a06908b5928cb5067 to your computer and use it in GitHub Desktop.
Save kapillamba4/a22093a1b4c3032a06908b5928cb5067 to your computer and use it in GitHub Desktop.
EXPRESSIONS
<div id="app">
<p>I have a {{ product }}</p>
<p>{{ product + 's' }}</p>
<p>{{ isWorking ? 'YES' : 'NO' }}</p>
<p>{{ product.getSalePrice() }}</p>
</div>
DIRECTIVES
#Element inserted/removed based on truthiness:
<p v-if="inStock">{{ product }}</p>
<p v-else-if="onSale">...</p>
<p v-else>...</p>
#Toggles the display: none CSS property:
<p v-show="showProductDetails">...</p>
#Two-way data binding:
<input v-model="firstName" >
v-model.lazy="..." #Syncs input after change event
v-model.number="..." #Always returns a number
v-model.trim="..." #Strips whitespace
LIST RENDERING
<li v-for="item in items" :key="item.id">
{{ item }}
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment