我有一个应用程序与多个滑动,幻灯片是由不同的服务器动态生成。如果swiper上只有一张幻灯片,我需要禁用导航和分页(没有子弹或swiper效果)。
我做了一些谷歌搜索,到目前为止,我只找到了Jquery的答案。我不允许使用Jquery,只能使用typescript。我试着用"document.querySelectorAll('.slider').length == 1“创建一个条件,但在DOM上找不到"slider”,所以总是返回0。
发布于 2019-06-27 04:46:47
所以我坚持了两天,终于找到了答案,它就像在swiper配置中添加"watchOverflow: true“一样简单:
public config: SwiperConfigInterface = {
slidesPerView: 1.16,
spaceBetween: 4,
centeredSlides: true,
mousewheel: true,
scrollbar: false,
navigation: false,
pagination: true,
watchOverflow: true
};https://stackoverflow.com/questions/56777664
复制相似问题