0👍
beforeCreate
is called immediately after the instance is initialized, after the resolution of the props, and before processing any further options like data() or calculated(). The difference between them is the beforeCreate
hook is before an instance has been fully initialized, whereas the created hook is after an instance is created.
data() {
return {
country: 'USA'
}
},
beforeCreate() {
this.country = 'Japan' // at this point country is undefined but
"this" is avalible
},
created() {
console.log(this.country) // 'USA'
}
- [Vuejs]-Firebase db with vuejs : default.collection is not a function
- [Vuejs]-How to access vue component data from socket.io listener function?
Source:stackexchange.com