Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 源码(1) #1

Open
yuan3140 opened this issue Feb 7, 2018 · 0 comments
Open

Vue 源码(1) #1

yuan3140 opened this issue Feb 7, 2018 · 0 comments

Comments

@yuan3140
Copy link
Owner

yuan3140 commented Feb 7, 2018

构造函数整理

// instance/index.js
function Vue (options) {
  this.init(options)
}
initMixin(Vue)
stateMixin(Vue)
eventsMixin(Vue)
lifecycleMixin(Vue)
renderMixin(Vue)

/****************************原型******************************/ 
// initMixin(Vue)
Vue.prototype._init = function (options) {}

// stateMixin(Vue)
Object.defineProperty(Vue.prototype, '$data', dataDef)
Object.defineProperty(Vue.prototype, '$props', propsDef)

Vue.prototype.$set = function set (target: Array<any> | Object, key: any, val: any): any {}
Vue.prototype.$delete = function del (target: Array<any> | Object, key: any) {}

Vue.prototype.$watch = function (
  expOrFn: string | Function,
  cb: any,
  options?: Object
): Function {}


// eventsMixin(Vue)
Vue.prototype.$on = function (event: string | Array<string>, fn: Function): Component {}
Vue.prototype.$once = function (event: string, fn: Function): Component {}
Vue.prototype.$off = function (event: string, fn: Function): Component {}
Vue.prototype.$emit = function (event: string): Component {}

// lifecycleMixin(Vue)
Vue.prototype._update = function (vnode: VNode, hydrating?: boolean) {}
Vue.prototype.$forceUpdate = function () {}
Vue.prototype.$destroy = function () {}

// renderMixin(Vue)
Vue.prototype.$nextTick = function (fn: Function) {}
Vue.prototype._render = function (): VNode {}

installRenderHelpers(Vue.prototype)
Vue.prototype._o = markOnce
Vue.prototype._n = toNumber
Vue.prototype._s = toString
Vue.prototype._l = renderList
Vue.prototype._t = renderSlot
Vue.prototype._q = looseEqual
Vue.prototype._i = looseIndexOf
Vue.prototype._m = renderStatic
Vue.prototype._f = resolveFilter
Vue.prototype._k = checkKeyCodes
Vue.prototype._b = bindObjectProps
Vue.prototype._v = createTextVNode
Vue.prototype._e = createEmptyVNode
Vue.prototype._u = resolveScopedSlots
Vue.prototype._g = bindObjectListeners



/****************************全局属性******************************/
// initGlobalAPI
Object.defineProperty(Vue, 'config', configDef)

Vue.util = {
  warn,
  extend,
  mergeOptions,
  defineReactive
}

Vue.set = set
Vue.delete = del
Vue.nextTick = nextTick

Vue.options = {
  components: {KeepAlive},
  directives: Object.create(null),
  filters: Object.create(null)
}
Vue.options._base = Vue

Vue.use = function (plugin: Function | Object) {}
Vue.extend = function (extendOptions: Object): Function {}
Vue.mixin = function (mixin: Object) {}

Vue.component =
Vue.directive =
Vue.filter = function (
  id: string,
  definition: Function | Object
): Function | Object | void {}
@yuan3140 yuan3140 changed the title vue 原理 vue 源码 Oct 31, 2018
@yuan3140 yuan3140 changed the title vue 源码 vue 源码(1) Nov 1, 2018
@yuan3140 yuan3140 changed the title vue 源码(1) Vue 源码(1) Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant