data() {
return {
property: value
}
}
Properties returned from data() become reactive state and will be exposed on
this
methods: {
function() {
code including this.property
}
}
Methods are functions that mutate state and trigger updates. They can be bound as event handlers in templates.
mounted() {
code
}
Lifecycle hooks are called at different stages of a component's lifecycle. This function will be called when the component is mounted
computed: {
fct() {
return code
}
}
Tracks other reactive state used in its computation as dependencies. It caches the result and automatically updates it when its dependencies change.
watch: {
prop() {
code
}
}
The watch callback is called when prop changes, and receives the new value as the argument
components: {
ChildComp
}
Register child component
inside child component
props: {
prop: value
}
Child component can accept input from the parent
inside child component
emits: ['eventName'],
created() {
this.$emit('eventName', '*additional arg')
}
Child component emits events to the parent
Comments