【问题标题】:ngx-owl-carousel-o options autoplay true not working?ngx-owl-carousel-o 选项自动播放真的不起作用?
【发布时间】:2021-04-20 11:22:41
【问题描述】:

我需要帮助如何让这个自动播放真正发挥作用。我写了这个问题,因为我找不到和我一样的问题。我真的需要你的眼睛看到错过或错过的东西。先谢谢大家了。

review-section.component.html

<div class="section section-review">
    <div class="container-fluid">
        <div class="container custom">
            <owl-carousel-o [options]="carouselOptions">
                <ng-template carouselSlide>
                    <img src="./assets/img/faces/joe-gardner-2.jpg">
                </ng-template>
                <ng-template carouselSlide>
                    <img src="./assets/img/faces/joe-gardner-2.jpg">
                </ng-template>
                <ng-template carouselSlide>
                    <img src="./assets/img/faces/joe-gardner-2.jpg">
                </ng-template>
                <ng-template carouselSlide>
                    <img src="./assets/img/faces/joe-gardner-2.jpg">
                </ng-template>
            </owl-carousel-o>
        </div>
    </div>
</div>

review-section.component.ts

import { Component, OnInit } from '@angular/core';
import { OwlOptions } from 'ngx-owl-carousel-o';

@Component({
  selector: 'app-review-section',
  templateUrl: './review-section.component.html',
  styleUrls: ['./review-section.component.css']
})
export class ReviewSectionComponent implements OnInit {

  constructor() { }
  carouselOptions: OwlOptions = {
    nav: false,
    loop: true,
    mouseDrag: true,
    touchDrag: true,
    pullDrag: true,
    dots: false,
    autoplay: true,
    navSpeed: 700,
    navText: ['', ''],
    responsive: {
      0: {
        items: 1
      },
      400: {
        items: 2
      },
      740: {
        items: 3
      },
      940: {
        items: 4
      }
    },
  }
  ngOnInit(): void {
  }

}

angular.json

"styles": [
   "node_modules/ngx-owl-carousel-o/lib/styles/prebuilt-themes/owl.carousel.min.css",
   "node_modules/ngx-owl-carousel-o/lib/styles/prebuilt-themes/owl.theme.default.min.css"
],

src/styles.scss

@import '../node_modules/ngx-owl-carousel-o/lib/styles/scss/owl.carousel.scss';
@import '../node_modules/ngx-owl-carousel-o/lib/styles/scss/owl.theme.default.scss';

【问题讨论】:

    标签: angular owl-carousel


    【解决方案1】:

    通过安装 ngx-owl-carousel-o 依赖修复

    npm i tslib

    【讨论】:

      【解决方案2】:

      试试这个....

      <ng-template carouselSlide class="item">
         <img src="./assets/img/faces/joe-gardner-2.jpg">
       </ng-template>
      

      .....在每个 ng 模板上

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 1970-01-01
      • 2022-09-28
      • 2023-02-15
      • 1970-01-01
      • 2022-01-01
      • 2018-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多