javascript - 未找到此依赖项 : *swiper/vue how to fix?

标签 javascript node.js vue.js webpack vue-component

我在挠头,因为我跑了 npm i swiper并通读 Swiper Vue 文档,它说 import { Swiper, SwiperSlide } from 'swiper/vue我已经完成了,我什至得到了显示 95.4K (gzipped: 28.9K) 的包大小.
当我运行 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
我一生都无法弄清楚如何导入该依赖项。

最佳答案

这对我有用,使用 Vue ^3.0.0 和 Swiper ^8.0.6

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

import "swiper/swiper-bundle.css";

关于javascript - 未找到此依赖项 : *swiper/vue how to fix?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69421228/

相关文章:

javascript - 如何更改代码以使图片位于 "main-block"中,而不是 js 代码?

jquery - bower 错误 : Failed UNABLE_TO_VERIFY_LEAF_SIGNATURE

node.js - Visual Studio 发布按钮被禁用?

javascript - 即使子网格没有使用 xml 的数据,jqGrid 也会显示 + 号

javascript - 使用 Node js 和 "connect-mongostore"的 session 存储

javascript - 创建一个用于长时间计算的加载屏幕

Javascript 日期解析错误?

vue.js - 在 Vue.js 的 eslint 中删除 'component has been registered but not used'

javascript - Vue 3 : Unable to update parent data from child component checkbox

vue.js - 在重新加载页面之前,Vuejs 在登录时看不到 localStorage 项目