【发布时间】: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 文件夹,然后我发现 Swiper 和 SwiperSlide 函数在哪里。所以我使用这一行导入了该文件。
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