낮은 인터페이스
4289 단어 typescript
import { Subject } from 'rxjs';
interface wh {
width: string;
height: string;
}
const sub = new Subject<wh>();
export function _resizeEvent(): Subject<wh> {
debugger;
window.addEventListener('resize', (ev) => {
let window = ev.target as Window;
let ele = window.document.activeElement as HTMLElement;
let width = ele.offsetWidth.toString();
let height = ele.offsetHeight.toString();
sub.next({ width: width, height: height });
});
return sub;
}
위의 코드를 사용하려면:
import { _resizeEvent } from './functions/observers';
_resizeEvent().subscribe(result=>{
this.width=result.width;
});
Intellisense는 이제 입력할 때 두 속성을 모두 보여줍니다.
인터페이스 정의는 클래스 정의와 달리 new 키워드를 지원하지 않습니다. 이것은 둘 사이의 거의 유일한 차이점입니다.
Reference
이 문제에 관하여(낮은 인터페이스), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/jwp/the-lowly-interface-4kd2텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)