为什么vue创建不用class而是用函数

源码中vue入口

function Vue (options) {
    if (!(this instanceof Vue)
    ) {
      warn('Vue is a constructor and should be called with the `new` keyword');
    }
    this._init(options);
  }
它实际上就是⼀个⽤ Function 实现的类,我们只能通过new Vue 去实例化它。
Vue 按功能把这些扩展分散到多个模块中去实现,⽽不是在⼀个模块⾥实现所有,这种⽅式是⽤ Class 难以实现的。这么做的好处是⾮常⽅便代码的维护和管理
posted @ 2020-06-12 11:46  TTtttt5  阅读(791)  评论(0编辑  收藏  举报