vue.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. var _ = require('./util')
  2. var extend = _.extend
  3. /**
  4. * The exposed Vue constructor.
  5. *
  6. * API conventions:
  7. * - public API methods/properties are prefiexed with `$`
  8. * - internal methods/properties are prefixed with `_`
  9. * - non-prefixed properties are assumed to be proxied user
  10. * data.
  11. *
  12. * @constructor
  13. * @param {Object} [options]
  14. * @public
  15. */
  16. function Vue (options) {
  17. this._init(options)
  18. }
  19. /**
  20. * Mixin global API
  21. */
  22. extend(Vue, require('./api/global'))
  23. /**
  24. * Vue and every constructor that extends Vue has an
  25. * associated options object, which can be accessed during
  26. * compilation steps as `this.constructor.options`.
  27. *
  28. * These can be seen as the default options of every
  29. * Vue instance.
  30. */
  31. Vue.options = {
  32. directives : require('./directives'),
  33. filters : require('./filters'),
  34. transitions : {},
  35. components : {},
  36. elementDirectives: {}
  37. }
  38. /**
  39. * Build up the prototype
  40. */
  41. var p = Vue.prototype
  42. /**
  43. * $data has a setter which does a bunch of
  44. * teardown/setup work
  45. */
  46. Object.defineProperty(p, '$data', {
  47. get: function () {
  48. return this._data
  49. },
  50. set: function (newData) {
  51. this._setData(newData)
  52. }
  53. })
  54. /**
  55. * Mixin internal instance methods
  56. */
  57. extend(p, require('./instance/init'))
  58. extend(p, require('./instance/events'))
  59. extend(p, require('./instance/scope'))
  60. extend(p, require('./instance/compile'))
  61. extend(p, require('./instance/misc'))
  62. /**
  63. * Mixin public API methods
  64. */
  65. extend(p, require('./api/data'))
  66. extend(p, require('./api/dom'))
  67. extend(p, require('./api/events'))
  68. extend(p, require('./api/child'))
  69. extend(p, require('./api/lifecycle'))
  70. module.exports = _.Vue = Vue