首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多个滑动器与onTouchStart同时移动

多个滑动器与onTouchStart同时移动
EN

Stack Overflow用户
提问于 2017-11-10 10:43:44
回答 1查看 648关注 0票数 1

我有一个页面(角4)与多个刷子,我想当触摸一个斯威珀(其中任何一个),所有的滑动在同一时间移动。实际上,当我触摸一个移动的刷卡时,这个刷卡可以工作,但是其他的刷卡不会移动。

我的HTML

代码语言:javascript
复制
<swiper [config]="config">
    <section class="swiper-wrapper">
      <article *ngFor="let article of articles" class="swiper-slide">
        <!--Code-->
      </article>
    </section>
    <div class="swiper-pagination"></div>
  </swiper>

  <!--Code-->

  <section *ngFor="let row of rows">
    <swiper [config]="config">
      <div class="swiper-wrapper">
        <span class="swiper-slide" *ngFor="let col of row.columns">
          <p *ngFor="let detail of col">{{detail}}</p>
        </span>
      </div>
    </swiper>
  </section>

将我的配置到ngOnInit

代码语言:javascript
复制
this.config = {
  slidesPerView: 'auto',
  centeredSlides: true,
  pagination: '.swiper-pagination',
  paginationClickable: true
};
EN

回答 1

Stack Overflow用户

发布于 2020-02-06 09:05:17

1.在index.html中添加下面提到的脚本和链接标记:

代码语言:javascript
复制
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.1/js/swiper.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.1/css/swiper.min.css">

2.在各滑块组件的“.ts”文件中添加以下功能。

代码语言:javascript
复制
declare var Swiper: any;

ngOnInit() {
   var mySwiper = new Swiper('.swiper-container', {
     direction: 'horizontal',
     loop: true,
     effect: 'slide',
     observer: true, 
      observeParents: true
    });
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47220968

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档