【发布时间】:2019-07-08 22:51:22
【问题描述】:
我想获得一个子组件中的 div 的 scrollWidth 和 offSetWidth,我将子组件加载为 ngx-datatable 中的 ngx-datatable-cell-template。我总是把值设为 0
我为 div 元素添加了模板变量,并使用 ViewChild 在组件中创建了一个变量。我试图从 ngAfterViewInit 方法中获取值。 variable.nativeElement.offsetWidth 总是给 0。我在子组件中做所有这些。
有人知道为什么这总是给出 0 值吗?
【问题讨论】:
标签: angular