2016-12-02 23 views

回答

2

我會說:

<div #width1> 
<div [style.width.px]="width2"> 

export class MyComponent 
{ 
width1: number; 
@ViewChild('width1') width1; 


ngAfterViewInit(){ 
    this.width2 = this.width1.nativeElement. width - 30; 

    } 
} 
+0

寬度1在ngAfterViewInit() – Dynamic

+0

它clientWidth工作未定義:) – Dynamic

相關問題