【发布时间】:2020-07-23 14:52:08
【问题描述】:
Swiper 滑块在 chrome 上没问题,但在 Internet Explorer 中,它不起作用我如何解决这个问题有人有解决方案吗?如果是请分享谢谢
【问题讨论】:
标签: javascript internet-explorer slider frontend swiper
Swiper 滑块在 chrome 上没问题,但在 Internet Explorer 中,它不起作用我如何解决这个问题有人有解决方案吗?如果是请分享谢谢
【问题讨论】:
标签: javascript internet-explorer slider frontend swiper
我在 IE 11 中测试了官方的演示,它不能工作。我发现 Swiper 从 v5 开始就放弃了对 IE 11 的支持。您可以查看this commit 和this thread。现在最新版本是 v6.0.4,所以在 IE 11 中无法使用。
如果你想在 IE 11 上使用 Swiper,我认为你可以使用支持 IE 的最新版本 v4.x。更多信息,您可以参考this thread。
【讨论】:
我对 Swiper 滑块进行了一些研究,发现 swiper 不适用于 Internet Explorer,但唯一适用于旧版浏览器的 2.xx 版本,我尝试过,但它不适合我。在对滑块进行了更多研究之后,我得到了一个与滑动器相同的 Slick 滑块。它也适用于 Internet Explorer 和其他浏览器。我像以前在 swiper 中一样做了一些代码
$('.slider').slick({
slidesToShow: 5,
slidesToScroll: 1,
speed: 500,
dots: true,
arrows: false,
centerMode: false,
focusOnSelect: false,
autoplay: true,
autoplaySpeed: 2000,
slide: 'div',
responsive: [
{
breakpoint: 900,
settings: {
slidesToShow: 4,
slidesToScroll: 1,
}
},
{
breakpoint: 425,
settings: {
slidesToShow: 3,
slidesToScroll: 1
}
},
{
breakpoint: 375,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});
使用此 HTML
<div class="slider">
<div class="item"><img src="images/logo1.png" alt="Logo"></div>
<div class="item"><img src="images/logo2.png" alt="Logo"></div>
<div class="item"><img src="images/logo3.png" alt="Logo"></div>
<div class="item"><img src="images/logo4.png" alt="Logo"></div>
<div class="item"><img src="images/logo5.png" alt="Logo"></div>
</div>
我还链接了cdn文件以获取更多信息,请访问官方slick网站here
【讨论】:
在我工作的公司,我们不得不支持 IE11,这是众所周知的令人头疼的问题。经过数小时的谷歌搜索和尝试不同的修复,我终于找到了一个!
我将 swiper 降级到 v3.4.2 并切换到使用 Swiper jQuery 文件而不是常规的 swiper.js 文件和 tada!成功了!
如果有人在 2021 年面临这个问题,那么这就是你的解决方案。
使用swiper.jquery.min.js 文件here。 v3.4.2 与最新版本相比,使用 swiper 的方式略有变化,因此您需要查看一些示例以使您的代码正常工作。
【讨论】: