简体   繁体   English

找不到此依赖项:*swiper/vue 如何修复?

[英]This dependency was not found: *swiper/vue how to fix?

I'm scratching my head because I ran npm i swiper and read through the Swiper Vue docs and it says to import { Swiper, SwiperSlide } from 'swiper/vue which I've done and I even get the bundle size showing 95.4K (gzipped: 28.9K) .我抓耳挠腮,因为我运行了npm i swiper并通读了 Swiper Vue 文档,它说import { Swiper, SwiperSlide } from 'swiper/vue我已经完成了,我什至得到了显示95.4K (gzipped: 28.9K)

When I run npm run serve I then get this error当我运行npm run serve我然后得到这个错误

This dependency was not found:

* swiper/vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/views/Home.vue?vue&type=script&lang=js

To install it, you can run: npm install --save swiper/vue

I for the life of me cannot figure out how to import that dependency.我终生无法弄清楚如何导入这种依赖性。

This worked for me, using Vue ^3.0.0 and Swiper ^8.0.6这对我有用,使用 Vue ^3.0.0 和 Swiper ^8.0.6

import { Swiper, SwiperSlide } from "swiper/vue/swiper-vue";

import "swiper/swiper-bundle.css";

If you're using the swiper version 7* then you could face this type of issue.如果您使用的是 swiper 版本 7*,那么您可能会遇到此类问题。

Github issue 4871 Github 问题 4871

Try downgrading to the v6.7.5, see if that helps.尝试降级到 v6.7.5,看看是否有帮助。

Related issue 相关问题

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

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