【问题标题】:SwipeJS not functioning properlySwipeJS 无法正常运行
【发布时间】:2021-09-02 13:48:47
【问题描述】:
My Swipe.Js version : "^7.0.2"

所以我今天尝试使用 Swipe.Js。当我导入时,我使用了这个代码行。

import { Swiper, SwiperSlide } from 'swiper/react'; 
as in https://swiperjs.com/react#installation.  But when I implement this I get error like this.
./src/App.jsx
Module not found: Can't resolve 'swiper/react' in 'C:\Users\User.LAPTOP-3EBUUP6S\Desktop\My future projects\new\smart-parking-system\src'

所以我查看了 node_modules 文件夹,然后我发现 SwiperSwiperSlide 函数在哪里。所以我使用这一行导入了该文件。 import { Swiper, SwiperSlide } from 'swiper/react/swiper-react.js';

但它也给出了这样的错误。

./node_modules/swiper/react/get-params.js
Module not found: Can't resolve 'swiper' in 'C:\Users\User.LAPTOP-3EBUUP6S\Desktop\My future projects\new\smart-parking-system\node_modules\swiper\react'

那么如何正确导入呢?我看到文档中有从 Swiper 6 到 7 的文件更改。(https://swiperjs.com/react#installation)但是显示(比如 该链接的样式导入)不起作用。所以我不得不查看 node_modules 然后进行导入。但是这个导入的 Swiper 和 SwiperSlide 是行不通的。这是为什么呢?

【问题讨论】:

    标签: javascript css reactjs swiper


    【解决方案1】:

    将您的版本降级到 6.8.4!它就像魔术一样工作!

    【讨论】:

    • 非常感谢。
    猜你喜欢
    • 2021-04-22
    • 2015-12-08
    • 2019-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多