Skip to content

Instantly share code, notes, and snippets.

@jesraygarciano
Created June 14, 2018 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesraygarciano/700e7831df4677b1a03d2f9fe111c215 to your computer and use it in GitHub Desktop.
Save jesraygarciano/700e7831df4677b1a03d2f9fe111c215 to your computer and use it in GitHub Desktop.
VUE ESSENTIALS CHEAT SHEET
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