Skip to content

Instantly share code, notes, and snippets.

@yyx990803
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yyx990803/c3f06a31b0c7fd3b6efc to your computer and use it in GitHub Desktop.
Save yyx990803/c3f06a31b0c7fd3b6efc to your computer and use it in GitHub Desktop.
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