Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. var myMixin = {
  2. data: function() {
  3. return {
  4. foo: 'bar',
  5. }
  6. },
  7. mounted: function() {
  8. console.log('mounted')
  9. }
  10. }
  11.  
  12. var component = {
  13. // pass mixins
  14. mixins: [myMixin],
  15.  
  16. data: function () {
  17. // component already have foo: 'bar' in data
  18. return {
  19. john: 'doe',
  20. }
  21. },
  22.  
  23. // component already have mounted hook inherited from mixin
  24. // in addition we can add one more mounted hook
  25. mounted: function () {
  26. console.log('component mounted')
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement