首页 > 解决方案 > angular 5 reInit owl carousel

问题描述

我可以在哪里运行函数 reInit() ngx-owl-carousel ?

我使用 ngx-owl-carousel 模块,并使用 angular 5,

如果路线改变猫头鹰旋转木马被刹车

<owl-carousel  #OwlElement class="col-12 col-xs-6 top-15"
             [options]="{
                items: 1,
                autoplay: true,
                autoplayTimeout: 5000,
                loop: true,
                margin:0,
                mouseDrag: true,
                singleItem: true,
                nav:false,
                dotClass: 'dots',
                dotsClass: 'dots-record',
                dots: true,   
                smartSpeed:1000,
                navSpeed: 1000
              }"
             [items]="[record_img]"
             [carouselClasses]="['owl-theme', 'row', 'sliding']">

标签: angularowl-carousel

解决方案


在您的组件中:

@ViewChild('OwlElement') OwlElement: OwlCarousel 

yourMethod() {
    this.OwlElement.reInit();
}

推荐阅读