首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于不同滑块的多种配置的ngx-滑动包装器

用于不同滑块的多种配置的ngx-滑动包装器
EN

Stack Overflow用户
提问于 2019-07-19 12:01:19
回答 1查看 2.6K关注 0票数 0

我正在使用ngx-刷卡-包装 npm软件包来实现两个不同配置的滑块在SPA站点的同一页面上。两个滑动块都是在不同的组件中创建的: brands.component和testimonials.component。

我的品牌模板如下:

代码语言:javascript
复制
<swiper [config]="BRANDS_SWIPER_CONFIG" [(index)]="index">
     <div class="swiper-slide">slide</div>
</swiper>

我的推荐信模板如下:

代码语言:javascript
复制
<swiper [config]="TESTIMONIALS_SWIPER_CONFIG" [(index)]="index">
     <div class="swiper-slide">              
     <div class="testimonial-item text-center"></div>
</swiper>

我的app.module

代码语言:javascript
复制
import { SwiperModule, SWIPER_CONFIG, SwiperConfigInterface } from 'ngx-swiper-wrapper';

const BRANDS_SWIPER_CONFIG: SwiperConfigInterface = {
   direction: 'horizontal',
   slidesPerView: 4,
   autoplay: { delay: 3000 },
   breakpoints:{ 640: { slidesPerView: 2 } }
 };

 const TESTIMONIALS_SWIPER_CONFIG: SwiperConfigInterface = {
      direction: 'horizontal',
      slidesPerView: 1,
 };

 @NgModule({
   providers: [
     CurrencyPipe,
     { provide: SWIPER_CONFIG, useValue: BRANDS_SWIPER_CONFIG },
     { provide: SWIPER_CONFIG, useValue: TESTIMONIALS_SWIPER_CONFIG }
  ],

TESTIMONIALS_SWIPER_CONFIG覆盖我的BRANDS_SWIPER_CONFIG,如何配置使我的证明模板接受TESTIMONIALS_SWIPER_CONFIG的设置

EN

回答 1

Stack Overflow用户

发布于 2020-02-06 09:18:00

代码语言:javascript
复制
1.Add the below mentioned script and link tag in index.html:
      <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.Add the below given function in '.html' file of respective swiper slider component.
      <div class="brands-container swiper-container">
            <div class="swiper-wrapper">
                  <div class="swiper-slide">              
                        <div class="brands-item text-center"></div>
                  </div>
            </div>
      </div>
      <div class="testimonial-container swiper-container">
            <div class="swiper-wrapper">
                  <div class="swiper-slide">              
                        <div class="testimonial-item text-center"></div>
                  </div>
            </div>
      </div>


3.Add the below given function in '.ts' file of respective swiper slider component.

      declare var Swiper: any;

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

https://stackoverflow.com/questions/57112108

复制
相关文章

相似问题

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