可以通过options->renderBullet自定义子弹,例如:
对于离子 4:
在 .html 文件中:
<ion-slides pager="true" [options]="options">
在 .ts 文件中:
options = {
pagination: {
el: '.swiper-pagination',
clickable: true,
renderBullet: function (index, className) {
if (index < 10) {
return '<span class="' + className + '">' + (index + 1) + '</span>';
}
return '';
},
},
}
或者您可以使用动态子弹,它显示最多 5 个点和一些过渡动画:
options = {
pagination: {
el: '.swiper-pagination',
dynamicBullets: true,
},
}
对于 Ionic3 试试这样:
import { ViewChild } from '@angular/core';
import { Slides } from 'ionic-angular';
class MyPage {
@ViewChild(Slides) slides: Slides;
ngAfterViewInit() {
this.slides.renderBullet= function (index, className) {
if (index < 10) {
return '<span class="' + className + '">' + (index + 1) + '</span>';
}
return '';
}
}
}
或者对于动态项目符号:
this.slides.dynamicBullets = "true";
在 html 中:
<ion-slides #slides pager="true">