【问题标题】:Can't click to button inside primeNg Carousel in responsive mode无法在响应模式下单击 PrimeNg Carousel 内的按钮
【发布时间】:2020-06-13 21:45:25
【问题描述】:

我在 Angular 项目中使用 PrimeNG v9,
当我切换到响应模式时,我无法点击轮播中的按钮,
每次我点击我都会得到轮播中的下一个项目。
这个问题有什么解决办法吗?

这是我的 HTML 内容:

<p-carousel [value]="services" [numVisible]="3" [numScroll]="1" [circular]="true"
    [responsiveOptions]="responsiveOptions">
    <ng-template let-service pTemplate="item" >
            <div class="img-bg2">
                <img src="{{service.url}}" class="bg-img" />
                <div class=" zero" [ngStyle]="{'background-color':  service.bgColor }"></div>
            </div>
            <div class="content content2">
                <h4>{{service.title}}</h4>
                <p>
                    {{service.body}}
                </p>
                <a routerLink="{{service.goTo}}">
                    EN SAVOIR PLUS
                </a>
            </div>
    </ng-template>
</p-carousel>

你可以在 primeNg 网站上测试它:

  1. 激活响应模式
  2. 尝试点击里面的按钮

PrimeNg's web site

【问题讨论】:

    标签: angular responsive-design carousel responsive primeng


    【解决方案1】:

    我找到了解决方案:
    我覆盖了轮播类中的 changePageOnTouch

    import {ElementRef, NgZone } from '@angular/core';
    import { Carousel } from 'primeng/carousel';
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.scss']
    })
    export class AppComponent extends Carousel {
    
      constructor(public el:ElementRef,
        public zone: NgZone) {
        super(el,zone);
        Carousel.prototype.changePageOnTouch = (e,diff) => {}
    }

    【讨论】:

    • 这对我有用,我们在我的项目中使用 prime-ng 轮播在移动模式下遇到了相同的情况
    • 这有效,但轮播项目上的滑动已停止。
    • 不幸的是我找不到解决方案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-25
    相关资源
    最近更新 更多