Javascript 在包ngx-owl-carousel-o中以角度触发owl carousel刷新
我希望我的猫头鹰旋转木马更新的响应选项。在jquery中,这可以通过使用:Javascript 在包ngx-owl-carousel-o中以角度触发owl carousel刷新,javascript,angular,owl-carousel-2,Javascript,Angular,Owl Carousel 2,我希望我的猫头鹰旋转木马更新的响应选项。在jquery中,这可以通过使用: $owl.trigger('refresh.owl.carousel') 正如这里提到的:(但是对于使用jquery作为依赖项的不同插件) 在api中,提到了refreshClass,但没有提到触发实例刷新 这可能吗?也一直在寻找答案。我的想法是使用@Viewchild访问元素,然后使用CarouselService。顺便问一下,你那边的情况如何@Anon也一直在寻找这个问题的答案。我的想法是使用@Viewchild访问
$owl.trigger('refresh.owl.carousel')代码>
正如这里提到的:(但是对于使用jquery作为依赖项的不同插件)
在api中,提到了refreshClass
,但没有提到触发实例刷新
这可能吗?也一直在寻找答案。我的想法是使用@Viewchild访问元素,然后使用CarouselService。顺便问一下,你那边的情况如何@Anon也一直在寻找这个问题的答案。我的想法是使用@Viewchild访问元素,然后使用CarouselService。顺便问一下,你那边的情况如何@Anon添加您的ViewChild:
@ViewChild('carousel', { static: true }) carousel: CarouselComponent;
检索您的服务
const anyService = this.carousel as any;
const carouselService = anyService.carouselService as CarouselService;
carouselService.refresh();
carouselService.update();
添加您的ViewChild:
@ViewChild('carousel', { static: true }) carousel: CarouselComponent;
检索您的服务
const anyService = this.carousel as any;
const carouselService = anyService.carouselService as CarouselService;
carouselService.refresh();
carouselService.update();
根据优步杰夫的建议,我找到了这个解决方案
@ViewChild('owlCar', { static: true }) owlCar: CarouselComponent;
.
.
@HostListener('window:resize', ['$event'])
onResize(event) {
let anyService = this.owlCar as any;
let carouselService = anyService.carouselService as CarouselService;
carouselService.onResize(event.target.innerWidth);
}
这不是一个优雅的解决方案,但它很有效基于UberGeoff的建议,我找到了这个解决方案
@ViewChild('owlCar', { static: true }) owlCar: CarouselComponent;
.
.
@HostListener('window:resize', ['$event'])
onResize(event) {
let anyService = this.owlCar as any;
let carouselService = anyService.carouselService as CarouselService;
carouselService.onResize(event.target.innerWidth);
}
这不是一个优雅的解决方案,但它很有效我最终没有使用旋转木马,而是渴望找到一个解决方案供将来使用。那么您使用了什么替代方案?现在我将跳过这方面的工作,但几周后我会回来寻找解决方案。我最终没有使用旋转木马,但我渴望找到一个解决方案供将来使用。那么您使用了什么替代方案?我现在将跳过这方面的工作,但几周后会回来寻找解决方案。