Vue项目作了很多,最近在学习设计模式与Vue源码,记录一下本身的脚印!共勉!注:此处源码学习方式为先了解其大模块,从宏观再去到微观学习,以避免一开始就研究细节而后出不来~vue
config.js 'web-full-dev': { entry: resolve('web/entry-runtime-with-compiler.js'), }
entry-runtime-with-compiler.js import config from 'core/config' import Vue from './runtime/index' export default Vue
runtime/index.js import Vue from 'core/index'
instance/index.js import { initMixin } from './init' import { stateMixin } from './state' import { renderMixin } from './render' import { eventsMixin } from './events' import { lifecycleMixin } from './lifecycle' import { warn } from '../util/index' function Vue (options) { if (process.env.NODE_ENV !== 'production' && !(this instanceof Vue) ) { warn('Vue is a constructor and should be called with the `new` keyword') } this._init(options) } initMixin(Vue) stateMixin(Vue) eventsMixin(Vue) lifecycleMixin(Vue) renderMixin(Vue) export default Vue
1.//初始化的入口,各类初始化工做 2.initMixin(Vue) 3.//数据绑定的核心方法,包括经常使用的$watch方法 4.stateMixin(Vue) 5.//事件的核心方法,包括经常使用的$on,$off,$emit方法 6.eventsMixin(Vue) 7.//生命周期的核心方法 8.lifecycleMixin(Vue) 9.//渲染的核心方法,用来生成render函数以及VNode 10.renderMixin(Vue)