當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript metal.computed函數代碼示例

本文整理匯總了TypeScript中@ember/-internals/metal.computed函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript computed函數的具體用法?TypeScript computed怎麽用?TypeScript computed使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了computed函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: computed

  /**
    The `type` attribute of the input element.

    @property type
    @type String
    @default "text"
    @public
  */
  type: computed({
    get(): string {
      return 'text';
    },

    set(_key: string, value: string) {
      let type = 'text';

      if (canSetTypeOfInput(value)) {
        type = value;
      }

      return type;
    },
  }),

  /**
    The `size` of the text field in characters.

    @property size
    @type String
    @default null
    @public
開發者ID:GreatWizard,項目名稱:ember.js,代碼行數:31,代碼來源:text_field.ts

示例2: computed

  /**
    Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass`
    CSS `class` to the element when the link is disabled.

    When `true` interactions with the element will not trigger route changes.
    @property disabled
    @private
  */
  disabled: computed({
    get(_key: string): boolean {
      // always returns false for `get` because (due to the `set` just below)
      // the cached return value from the set will prevent this getter from _ever_
      // being called after a set has occured
      return false;
    },

    set(_key: string, value: any): boolean {
      (this as any)._isDisabled = value;

      return value ? get(this, 'disabledClass') : false;
    },
  }),

  _isActive(routerState: any) {
    if (get(this, 'loading')) {
      return false;
    }

    let currentWhen = get(this, 'current-when');

    if (typeof currentWhen === 'boolean') {
開發者ID:habdelra,項目名稱:ember.js,代碼行數:31,代碼來源:link-to.ts

示例3: init

    @for Ember.Templates.helpers
    @param {Hash} options
    @public
  */
  Input = Component.extend({
    tagName: '',

    init() {
      if (DEBUG) {
        this[DISABLE_TAGLESS_EVENT_CHECK] = true;
      }
      this._super(...arguments);
    },

    isCheckbox: computed('type', function(this: { type?: unknown }) {
      return this.type === 'checkbox';
    }),

    __injectEvents(target: any) {
      let eventDispatcher = getOwner(this).lookup<any | undefined>('event_dispatcher:main');
      let events: Dict<string> = (eventDispatcher && eventDispatcher._finalEvents) || {};
      Object.values(events).forEach(key => {
        if (this[key]) {
          target[key] = this[key];
        }
      });
    },
  });

  Input.toString = () => '@ember/component/input';
開發者ID:mixonic,項目名稱:ember.js,代碼行數:30,代碼來源:input.ts


注:本文中的@ember/-internals/metal.computed函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。