【问题标题】:How can I use swiper on IE? is there any solution?如何在 IE 上使用 swiper?有什么解决办法吗?
【发布时间】:2020-07-23 14:52:08
【问题描述】:

Swiper 滑块在 chrome 上没问题,但在 Internet Explorer 中,它不起作用我如何解决这个问题有人有解决方案吗?如果是请分享谢谢

【问题讨论】:

    标签: javascript internet-explorer slider frontend swiper


    【解决方案1】:

    我在 IE 11 中测试了官方的演示,它不能工作。我发现 Swiper 从 v5 开始就放弃了对 IE 11 的支持。您可以查看this committhis thread。现在最新版本是 v6.0.4,所以在 IE 11 中无法使用。

    如果你想在 IE 11 上使用 Swiper,我认为你可以使用支持 IE 的最新版本 v4.x。更多信息,您可以参考this thread

    【讨论】:

    • 感谢您的回答!但是我得到了我尝试过的解决方案 v2.xx 这是适用于 IE 的版本,但它不起作用,经过一番研究后,我发现我使用了 swiper 的替代滑块,这是一个适用于 IE 的光滑滑块。
    • 很高兴您解决了这个问题!您还可以将您的详细解决方案发布为答案,并在 48 小时后将您的答案标记为已接受的答案,此时可以标记。它可以在未来帮助其他社区成员解决类似的问题。感谢您的理解。
    • 当然!我会更新答案。谢谢你告诉我
    • 我有 swiper 5.4.5 并且在 IE11 中运行良好。我确认 tat swiper 6 没有。
    【解决方案2】:

    我对 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

    【讨论】:

      【解决方案3】:

      在我工作的公司,我们不得不支持 IE11,这是众所周知的令人头疼的问题。经过数小时的谷歌搜索和尝试不同的修复,我终于找到了一个!

      我将 swiper 降级到 v3.4.2 并切换到使用 Swiper jQuery 文件而不是常规的 swiper.js 文件和 tada!成功了!

      如果有人在 2021 年面临这个问题,那么这就是你的解决方案。

      使用swiper.jquery.min.js 文件here。 v3.4.2 与最新版本相比,使用 swiper 的方式略有变化,因此您需要查看一些示例以使您的代码正常工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-01-28
        • 2010-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多