In Vue.js docs I've found two ways of defining data so far: data: {} and data() { return; }.
data: {
defaultLayout: 'default'
}
data() {
return {
defaultLayout: 'default'
}
}
So far, I don't have any clue about third ways: data: () => ({}). How it makes differ from above two's.
data: () => ({
defaultLayout: 'default'
})
datamust be a function returning an object. It is in order to avoid passing an object reference which would be modified somewhere else. vuejs.org/v2/guide/components.html#data-Must-Be-a-Function