A VueJS Cheatsheet For Developers by LearnVue - Co - LearnVue-Vue-3-Cheatsheet
A VueJS Cheatsheet For Developers by LearnVue - Co - LearnVue-Vue-3-Cheatsheet
Can use JS Expressions; NOT JS Statements Method is passed a Native DOM Cvent
<span> {{ msg.reverse() }} </span> const count = (event) => {
<span> {{ let msg = 'hi' }} </span> console.log(event.target)
}
DIRECTIVES
v-if Puts el in DOM if true Event modiers (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
1
VUE 3 CHEATSHEET FOR DEVELOPERS
Put together by your friends at learnvue.co
2
VUE 3 CHEATSHEET FOR DEVELOPERS
Put together by your friends at learnvue.co
<keep-alive>
EXAMPLE LIFECYCLE HOOK CODE
<component :is='componentName'/>
</keep-alive>
import { onMounted } from 'vue'
// ...
COMPOSITION API setup() {
Everything returned by setup() is exposed to onMounted(() => {
the template. console.log('component mounted!')
}
}
import { ref, reactive } from 'vue'
export default {
setup(props, context) { VUE GLOBAL METHODS
const val = ref('example')
const obj = reactive({ count: 0 })
mount() Mount component to DOM
3
VUE 3 CHEATSHEET FOR DEVELOPERS
Put together by your friends at learnvue.co
// template
<div ref='example'> Example Div </div> CONTACT
// script
setup() { For any corrections, comments, or concerns,
const example = ref('learnvue.co') just contact me at matt@learnvue.co
// wait for DOM to mount
onMounted(() => {
Hope this helped!
console.log(example.value)
})
return { example }
}