【发布时间】:2018-07-11 18:03:09
【问题描述】:
我想使用我动态添加的多个IonicSlides。但我不能使用@viewChild。请提出解决此问题的方法。
模板.html:
<div *ngFor="let name of title;let i = index;">
<ion-slides id="something" #slides>
//some code
</ion-slides>
</div
Component.ts:
@ViewChild('slides') slides: QueryList<Slides>;
....
ngAfterViewInit(){
setTimeout(()=>{
alert(this.slides.toArray()); //this line rise error
}, 3000);
}
错误:
_this.slides.toArray 不是函数
【问题讨论】:
-
请不要使用警报进行调试,现在是 2020 年
-
@refaelio 问题是 2 年前的问题,不是 2020 年。哈哈
-
@Mohsen 2018 年和 2020 年一样糟糕,只是听起来没有那么酷,哈哈
-
@Mohsen 这只是一个比喻
标签: javascript angular ionic2 viewchild