Last active
August 29, 2015 14:09
-
-
Save yyx990803/c3f06a31b0c7fd3b6efc to your computer and use it in GitHub Desktop.
This file contains 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
var vm = new Vue({ | |
components: { | |
example: { | |
data: function () { | |
return { a: 1 } | |
} | |
} | |
} | |
}) | |
// modify the component options | |
var Example = vm.$options.compoentns.example // <- this is a constructor | |
var rawDataFn = Example.options.data | |
// wrap the raw data fn | |
Example.options.data = function () { | |
var raw = rawDataFn() // -> { a: 1 } | |
raw.b = 2 | |
return raw // -> { a: 1, b: 2 } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment