本文整理汇总了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;未经允许,请勿转载。 |
请发表评论