我是新來的打字稿,我正在嘗試爲angular 2指令創建一個函數。 任何人都可以用n00bs的語言解釋,當我用Gulp編譯時,錯誤是想告訴我什麼?angular 2 typescript一個實現不能在環境中聲明
的實現不能在周圍環境
的信息適用於offset()
和toggler()
聲明。
import { Directive, ElementRef, Input } from '@angular/core';
@Directive({
selector: 'offCanvas',
inputs: ['target', 'toggle', 'placement', 'autohide', 'recalc', 'disableScrolling', 'modal', 'canvas', 'exclude'],
host: {
'(click)': 'Click()'
}
})
export class OffCanvas {
@Input('target') target: string;
@Input('canvas') canvas: string;
@Input('state') state: string;
@Input('exclude') exclude: string;
@Input('placement') placement: string;
@Input('toggle') toggle: boolean;
@Input('autohide') autohide: boolean;
@Input('recalc') recalc: boolean;
@Input('disableScrolling') disableScrolling: boolean;
@Input('modal') modal: boolean;
public offset() {
switch (this.placement) {
case 'left':
case 'right': return (<HTMLElement>document.querySelector(this.target)).offsetWidth
case 'top':
case 'bottom': return (<HTMLElement>document.querySelector(this.target)).offsetHeight
}
}
public toggler() {
if (this.state === 'slide-in' || this.state === 'slide-out') return
this[this.state === 'slid' ? 'hide' : 'show']()
}
Click() {
this.toggler()
}
}
我覺得很愚蠢...... – poashoas
別擔心。所以我的https://en.wikipedia.org/wiki/Impostor_syndrome – basarat
大聲笑,這個綜合症讓我做到了 – poashoas