The error information is as follows:
Module not found: Error: Package path ./swiper.css is not exported from package C:\Users\yoyang\Desktop\vue\test2022\node_modules\swiper (see exports field in C:\Users\yoyang\Desktop\vue\test2022\node_modules\swiper\package.json)
The reason for the problem is that vue2 has poor compatibility with the latest version of swipe. You only need to reinstall the old version of swipe, such as [email protected]
Solution:
1. Download the old version of swiper
npm i [email protected] --save
2. Restart project
npm run serve
3. Import swiper
import Swiper from 'swiper/bundle'
import 'swiper/swiper-bundle.css'
In this way, the wiper component can be used normally
<template>
<div class="swiper-container yang">
<div class="swiper-wrapper">
<slot></slot>
</div>
<div class="swiper-pagination"></div>
</div>
</template>
<script>
import Swiper from 'swiper'
import 'swiper/swiper.min.css'
export default {
mounted () {
new Swiper('.yang', {
pagination: {
el: '.swiper-pagination'
},
loop: this.loop,
autoplay: {
delay: 2500,
disableOnInteraction: false
}
})
}
}
</script>
Read More:
- Vue Import element-plus Error: Failed to resolve import “element-pluslibtheme-chalkindex.css“ from “src
- Vue JS import font.css error [How to Solve]
- Full screen scrolling by Vue + Vue awesomeswiper
- Vue Start Error: This relative module was not found:
- [Solved] Vue Project Error: This relative module was not found
- [Solved] Vue Route Error: Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_42__.defineComponent) is not a function
- [Solved] Vue Error: Module build failed: Error: No PostCSS Config found in
- [Solved] vue3vite Error: Failed to resolve import “@vue/server-renderer from “src\App.vue“. Does the file exist
- Vue Dynamic Display Picture Error 404: Not Found [How to Solve]
- vue3 import Error: has no default export [How to Solve]
- [Solved] Vue E-Charts Error: These dependencies were not found:
- Vue Project Error: Expected indentation of 2 spaces but found 4,Newline required at end of file but not found
- Vue Startup Error: 98% after emitting CopyPlugin This dependency was not found:
- Module not found: Error: Can‘t resolve ‘core-js/modules/es.promise.js‘ in
- How to Solve Vue3 Import lodash error
- [Solved] SyntaxError: Cannot use import statement outside a module
- [Solved] Vue-cli Error: Module not found: Error: Can‘t resolve ‘vue-router ‘
- [Solved] Uncaught SyntaxError: Cannot use import statement outside a module
- [Solved] SyntaxError: Cannot use import statement outside a module
- [Solved] Module build failed: Error: Vue packages version mismatch