在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ Vue.extend與 Vue.util.extend 有啥區(qū)別

Vue.extend與 Vue.util.extend 有啥區(qū)別

Vue.extend與 Vue.util.extend 有啥區(qū)別?
Vue2.0的文檔里面沒(méi)有Vue.util相關(guān)的說(shuō)明啊,但是 weex 的 demo 中有下面的語(yǔ)句
new Vue(Vue.util.extend({ el: '#root', router, store }, App))

回答
編輯回答
伐木累

Vue.extend 和 Vue.util.extend 在 vue.runtime.js 文件中是這么定義的。

  Vue.util = {
    warn: warn,
    extend: extend,
    mergeOptions: mergeOptions,
    defineReactive: defineReactive$$1
  };

 /**
  * Mix properties into target object.
  */
  function extend (to, _from) {
    for (var key in _from) {
      to[key] = _from[key];
    }
    return to
  }

  /**
   * Class inheritance
   */
  Vue.extend = function (extendOptions) {
    extendOptions = extendOptions || {};
    var Super = this;
    
    /* ... */
    
    var Sub = function VueComponent (options) {
      this._init(options);
    };
    
    /* ... */
    
    return Sub
  };
    

Vue.util.extend 的主要作用就是合并 { el: '#root', router, store } App就這么簡(jiǎn)單。

2017年6月28日 15:52