我目前面临着将断点集成到Swiper代码中的挑战.尽管我进行了try ,但我仍无法成功实现断点,而且该功能似乎没有按预期工作.我正在询问是否有其他人遇到过类似的问题,或者是否有关于在此特定代码中实现断点的成功 case .对解决这一问题的任何指导或见解都将不胜感激.
Html:
<div>
<swiper-container style="--swiper-navigation-color: #fff; --swiper-pagination-color: #fff" class="mySwiper"
thumbs-swiper=".mySwiper2" space-between="10" navigation="true">
<swiper-slide *ngFor="let slide of slides">
<img [src]="slide.image" />
</swiper-slide>
</swiper-container>
<swiper-container class="mySwiper2" space-between="10" slides-per-view="6" free-mode="true"
watch-slides-progress="true">
<swiper-slide *ngFor="let slide of slides">
<img [src]="slide.image" />
</swiper-slide>
</swiper-container>
</div>
SCSS:
/* You can add global styles to this file, and also import other style files */
swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
display: flex;
justify-content: center;
align-items: center;
background-size: cover;
background-position: center;
img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
}
.mySwiper {
// defines height and width of main swiper
height: 600px;
width: 600px;
}
.mySwiper2 {
// defines height and width of thumbs swiper
height: 100px;
width: 600px;
box-sizing: border-box;
padding: 10px 0;
swiper-slide {
opacity: 0.6; // this set default opacity to all slides
}
.swiper-slide-thumb-active {
opacity: 1; // this reset the opacity one for the active slide
}
}
S:
import { CommonModule } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
@Component({
selector: 'app-thumbs-default',
standalone: true,
imports: [CommonModule],
templateUrl: './thumbs-default.component.html',
styleUrl: './thumbs-default.component.scss',
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class ThumbsDefaultComponent {
slides = [
{image: 'https://swiperjs.com/demos/images/nature-1.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-2.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-3.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-4.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-5.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-6.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-7.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-8.jpg'},
{image: 'https://swiperjs.com/demos/images/nature-10.jpg'}
];
}