首页 > 解决方案 > ember.js 中的 proto() 是什么意思?

问题描述

谁能解释这一行中的 proto() 是什么意思?它来自余烬代码。

Client.Details.proto().set('isAdminUser',win.isAuthenticatedAdmin);

标签: javascriptember.js

解决方案


它是 ember.js 用来初始化其原型的。

您可以深入了解其来源

Class.proto = function() {
    var superclass = Class.superclass;
    if (superclass) { superclass.proto(); }

    if (!wasApplied) {
      wasApplied = true;
      Class.PrototypeMixin.applyPartial(Class.prototype);
      Ember.rewatch(Class.prototype); // setup watch chains if needed.
      hasChains = !!meta(Class.prototype, false).chains; // avoid rewatch
    }

   return this.prototype;
};

推荐阅读