A VueJS Cheatsheet For Developers by LearnVue - Co
A VueJS Cheatsheet For Developers by LearnVue - Co
Can use JS Expressions; NOT JS Statements Method is passed a Native DOM Cvent
✅ <span> {{ msg.reverse() }} </span>
❌ <span> {{ let msg = 'hi' } } </span>
const count = (event) => {
console.log(event.target)
}
DIRECTIVES
v-if Puts el in DOM if true Event modifiers (usage: v-on:click.stop)
v-else Like a usual conditional .once Can only trigger event once
v-text Sets the inner text .self Don't send if target = child
2
VUE3 CHEATSHEET FOR DEVELOPERS
Put together by your friends at learnvue.co
SETUP() CONTEXT OBJECT PROPERTIES
Parent Has Access to MyButton post data
<my-button> attrs Has component's attributes
<template v-slot:default='slotData'> slots Has component's slots
{{ post.author }}
emit Function to emit events
</template>
</my-button>
VUEJS LIFECYCLE HOOKS
DYNAMIC COMPONENTS *beforeCreate Use setup() instead
Changes the rendered component - finds a
registered component with the given name. *created Use setup() instead
onBeforeMount Before mounting DOM
<component :is='componentName'/
> onMounted DOM can be accessed
return { example }
}
4