Skip to content

Instantly share code, notes, and snippets.

@nolimits4web
Created October 4, 2019 14:54
Show Gist options
  • Save nolimits4web/99b8334cb09e892024e360ecd4e79593 to your computer and use it in GitHub Desktop.
Save nolimits4web/99b8334cb09e892024e360ecd4e79593 to your computer and use it in GitHub Desktop.
var myMixin = {
data: function() {
return {
foo: 'bar',
}
},
mounted: function() {
console.log('mounted')
}
}
var component = {
// pass mixins
mixins: [myMixin],
data: function () {
// component already have foo: 'bar' in data
return {
john: 'doe',
}
},
// component already have mounted hook inherited from mixin
// in addition we can add one more mounted hook
mounted: function () {
console.log('component mounted')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment