為什么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 難以實現的。這么做的好處是⾮常⽅便代碼的維護和管理


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM