-
Check that this is really a bug
Reproduction linkhttps://github.com/earthrule/nuxt-swiper-error Bug descriptionHello, the technology stack for this problem is to use swiper in nuxt.js,Before that, I completely followed the steps in the https://swiperjs.com/vue documentation, installed via <template>
<swiper
:slides-per-view="3"
:space-between="50"
@swiper="onSwiper"
@slideChange="onSlideChange"
>
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
...
</swiper>
</template>
<script>
// Import Swiper Vue.js components
import { Swiper, SwiperSlide } from 'swiper/vue';
// Import Swiper styles
import 'swiper/css';
export default {
components: {
Swiper,
SwiperSlide,
},
setup() {
const onSwiper = (swiper) => {
console.log(swiper);
};
const onSlideChange = () => {
console.log('slide change');
};
return {
onSwiper,
onSlideChange,
};
},
};
</script> to write a demo component, but after starting the project through
I searched in swiper according to these two bugs respectively, according to the workaround in #4315:
But it didn't help, then I followed #4871 to use Swiper 6, but still got the above error and couldn't run. After that, I followed the method of #5064 (comment) to modify, good news is: the error disappeared, but the bad news is that he Another bunch of errors came up and didn't display properly. On this basis, I changed the demo provided by swiper, but the error still occurred I hope you can help me understand how to solve it if I have encountered a similar problem, thank you very much Expected BehaviorNo response Actual BehaviorNo response Swiper version8.2.4 Platform/Target and Browser VersionsWindows; Node v16.15.1; Chromium 102.0.5005.124 Validations
Would you like to open a PR for this bug?
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
This question, after asking my friend @XiaoLi-sach and operation, has found the problem, maybe swiper 6, 7, 8 are based on Vue3 caused by `Error: Can't resolve 'swiper /vue' error, so a more conservative suggestion is to use the vue-2 version of https://github.com/surmon-china/vue-awesome-swiper to solve it. Very sorry, I shouldn't use vue2 to test swiper 8\6\7 support for him. |
Beta Was this translation helpful? Give feedback.
-
FWIW I'm using vue3 and observed the same behavior when following the instructions listed above. I was using storybook, storybook still defaults to webpack 4, swiper has some magic export in package.json that requires webpack 5 storybook isn't willing to update such a major dependency in a minor release, so they have an optional step to get you to webpack 5 which will resolve the problem |
Beta Was this translation helpful? Give feedback.
-
using webpack 4 you can import like this |
Beta Was this translation helpful? Give feedback.
-
"swiper": "^11.1.4", |
Beta Was this translation helpful? Give feedback.
using webpack 4 you can import like this
import { Swiper, SwiperSlide } from 'swiper/swiper-vue.mjs';
import 'swiper/swiper.css';