Vue2.6.x源码阅读 - 5.源码阅读-core-Vue构造函数
Vue构造函数
/* Vue 构造函数 */ function Vue (options) { // 入参 options 即为开发者new一个Vue实例时,Vue中传入的带有data、method、watch等属性的对象,在日常代码中,直接使用 this 指代。 if (process.env.NODE_ENV !== 'production' && !(this instanceof Vue) // 判断是否通过 new 调用 Vue 构造函数 ) { warn('Vue is a constructor and should be called with the `new` keyword') } this._init(options) // 初始化 Vue 实例,方法定义于 Vue 的 prototype 中 } initMixin(Vue) // 混入初始化方法,构造函数中的 Vue.prototype._init()方法来自于其中 stateMixin(Vue) // 混入 状态处理 的方法 eventsMixin(Vue) // 混入 事件 的方法 lifecycleMixin(Vue) // 混入 生命周期 的方法 renderMixin(Vue) // 混入 渲染相关 的方法 export default Vue
initMixin
最后更新于
