我有个问题:
将ElementRef.nativeElement用于读取属性值(例如'scrollHeight')计为DOM交互并因此打破Angular Universal?
ElementRef似乎是从元素中读取属性的唯一方法:https://stackoverflow.com/a/38037240/5565132
例:
HTML:
<div #test1></div>
Run Code Online (Sandbox Code Playgroud)
TS:
@ViewChild('test1') test1: ElementRef;
ngOnInit() {
console.log(this.test1.nativeElement.scrollHeight);
}
Run Code Online (Sandbox Code Playgroud)