Why the results are different for using () => and function() in mounted:
export default {
mounted: () => {
this.socket = 'something'
console.log('mounted')
},
methods: {
submitMessage() {
console.log(this.socket) // undefined
}
}
}
Using function():
export default {
mounted: function() {
this.socket = 'something'
console.log('mounted')
},
methods: {
submitMessage() {
console.log(this.socket) // something
}
}
}
Any ideas?