Last active
February 9, 2017 20:58
-
-
Save asselin/0b9c1da1015858bd58d7423cba1645bd to your computer and use it in GitHub Desktop.
Dynamically extending a Vue Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Vue from 'Vue'; | |
| beforeCreate () { | |
| this.$options = Vue.util.mergeOptions({ | |
| data: function() { | |
| return { | |
| selectedItem: 8 | |
| } | |
| }, | |
| computed: { | |
| computeFoo: function() { | |
| return this.selectedItem * 2; | |
| } | |
| }, | |
| methods: { | |
| foo: function() { | |
| console.log('hello'); | |
| } | |
| } | |
| }, this.$options, this); | |
| // From a passed in prop | |
| this.$options = Vue.util.mergeOptions(this.$options.propsData.passedInMixin, this.$options, this); | |
| }, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment