简体   繁体   English

如何在 IE 上使用 swiper? 有什么解决办法吗?

[英]How can I use swiper on IE? is there any solution?

Swiper slider is okay on chrome but in the internet explorer, it is not working how I fix this anyone has a solution of this? Swiper slider 在 chrome 上没问题,但在 Internet Explorer 中,它不起作用我如何解决这个问题有人有解决方案吗? if yes please share it Thanks如果是请分享谢谢

I tested the official demo in IE 11 and it can't work.我在 IE 11 中测试了官方的演示,它不能工作。 I found that Swiper has dropped IE 11 support since v5.我发现 Swiper 从 v5 开始就放弃了对 IE 11 的支持。 You could check this commit and this thread .你可以检查这个提交这个线程 Now the latest version is v6.0.4 so it can't work in IE 11.现在最新版本是 v6.0.4,所以它不能在 IE 11 中运行。

If you want to use Swiper on IE 11, I think you can use v4.x which is the latest version that supports IE.如果你想在 IE 11 上使用 Swiper,我认为你可以使用支持 IE 的最新版本 v4.x。 For more information, you could refer to this thread .有关更多信息,您可以参考此线程

I do some research on Swiper slider and I got that swiper didn't work for Internet Explorer but the only version 2.xx version that works for an older browser, I tried but it didn't work for me.我对 Swiper slider 做了一些研究,我发现 swiper 不适用于 Internet Explorer,但唯一适用于旧版浏览器的 2.xx 版本,我试过了,但它对我不起作用。 After done a little more research on sliders then I got a Slick slider that works the same as swiper.在对滑块进行了更多研究之后,我得到了一个与滑动器相同的 Slick slider。 It also works for Internet Explorer and other browsers.它也适用于 Internet Explorer 和其他浏览器。 I do some sud of code as I did before in the swiper我像以前在 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
  ]
});

with this HTML用这个 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>

I also linked the cdn files for more information please visit the official slick site here我还链接了cdn文件以获取更多信息,请在此处访问官方网站

At the company I work at, we had to support IE11 which is a headache like everyone knows.在我工作的公司,我们不得不支持 IE11,这是众所周知的令人头疼的问题。 After hours of googling and trying out different fixes, I finally found one!经过数小时的谷歌搜索和尝试不同的修复,我终于找到了一个!

I downgraded swiper to v3.4.2 and switched to using the Swiper jQuery file instead of the regular swiper.js file and tada!我将 swiper 降级到 v3.4.2 并切换到使用 Swiper jQuery 文件而不是常规的swiper.js文件和 tada! it worked!有效!

If anyone is facing this issue in 2021, this is the fix for you.如果有人在 2021 年遇到此问题,那么这就是您的解决方案。

Use the swiper.jquery.min.js file here .此处使用swiper.jquery.min.js文件。 The way to use swiper changes a little bit in v3.4.2 from the latest version so you'd need to look at some of the examples to make your code works correctly.使用 swiper 的方式在 v3.4.2 中与最新版本相比略有变化,因此您需要查看一些示例以使您的代码正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM