Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod is not a function #81

Open
impronta48 opened this issue Aug 24, 2023 · 9 comments
Open

mod is not a function #81

impronta48 opened this issue Aug 24, 2023 · 9 comments

Comments

@impronta48
Copy link

I'm running a nuxt 3 project, with simple installation of this module.

I'm running a sample page exaclty as the example, but I get:

Uncaught (in promise) TypeError: mod is not a function
    at swiper-core.mjs:3065:7
    at Array.forEach (<anonymous>)
    at new Swiper (swiper-core.mjs:3064:20)
    at setup (swiper-vue.mjs:594:23)
    at callWithErrorHandling (chunk-VWWL2I6E.js:1565:18)
    at setupStatefulComponent (chunk-VWWL2I6E.js:8631:25)
    at setupComponent (chunk-VWWL2I6E.js:8592:36)
    at mountComponent (chunk-VWWL2I6E.js:6997:7)
    at processComponent (chunk-VWWL2I6E.js:6963:9)
    at patch (chunk-VWWL2I6E.js:6436:11)

this error goes away only removing the :modules attribute from Swiper (but of course the result is not the one I want ;-)

Can you help?
Thanks
Massimo

@cpreston321
Copy link
Owner

Can you submit a reproduction 🙏🏼 ?

@impronta48
Copy link
Author

What can I provide? My package.json?

Is this happening only to me?

@cpreston321
Copy link
Owner

Copy the code in stackblitz url on the README, copy your code to see if you can replicate it on that environment.

@alexrichardsweb
Copy link

Are you including the modules as strings e.g. :modules=['SwiperNavigation', 'SwiperPagination']? I ask because I had this same issue and that is what I was doing wrong - It needs to be an array of modules e.g. :modules=[SwiperNavigation, SwiperPagination]

@cpreston321
Copy link
Owner

@omgzsa
Copy link

omgzsa commented Sep 11, 2023

I have the exact same issue. const swiper = useSwiper() is undefined as well, the documentation doesn't tell much about the usage. I inserted the stackblitz code in my project, it's also just somewhat working.

<template>
  <div class="py-16 space-y-10 site-padding">
    <h2>Featured categories</h2>
    <Swiper
      :height="300"
      :modules="[SwiperPagination]"
      :slides-per-view="1"
      :pagination="{ clickable: true }"
      :space-between="5"
      class="swiper swiper-cards"
    >
      <SwiperSlide v-for="slide in slides" :key="slide.id">
        <HomeCategoriesCard
          :title="slide.title"
          :alt="slide.title"
          :img="useAsset(`images/homepage/${slide.img}`)"
        />
      </SwiperSlide>
      <SwiperPagination />
    </Swiper>
  </div>
</template>
[Vue warn]: Failed to resolve component: SwiperPagination
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. 
  at <Categories> 
  at <Index onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > > 
  at <RouteProvider key="/" vnode= {__v_isVNode: true, __v_skip: true, type: {…}, props: {…}, key: null, …} route= {fullPath: '/', hash: '', query: {…}, name: 'index', path: '/', …}  ... > 
  at <BaseTransition onAfterLeave= [ƒ] mode="out-in" appear=false  ... > 
  at <Transition onAfterLeave= [ƒ] name="page" mode="out-in" > 
  at <RouterView name=undefined route=undefined > 
  at <NuxtPage> 
  at <Default ref=Ref< undefined > > 
  at <LayoutLoader key="default" layoutProps= {ref: RefImpl} name="default" > 
  at <NuxtLayoutProvider layoutProps= {ref: RefImpl} key="default" name="default"  ... > 
  at <NuxtLayout> 
  at <App key=3 > 
  at <NuxtRoot>

@0Shino0
Copy link

0Shino0 commented Dec 7, 2023

I encountered this problem when refactoring a vue3 project into nuxt3, and I think it may be because nuxt-swiper changed some of the modules names. Because I triggered this error by copying the original swiper configuration, This problem is solved when I :modules="[EffectCoverflow, SwiperNavigation]" is changed to :modules="[SwiperEffectCoverflow, SwiperNavigation]"。A specific module name, you can check https://nuxt.com/modules/swiper#usage

@WuChenDi
Copy link

Hello, everyone.
I would like to inquire whether this issue has been addressed. I noticed that it persists on StackBlitz.

image

@saint-james-fr
Copy link

I encountered this problem when refactoring a vue3 project into nuxt3, and I think it may be because nuxt-swiper changed some of the modules names. Because I triggered this error by copying the original swiper configuration, This problem is solved when I :modules="[EffectCoverflow, SwiperNavigation]" is changed to :modules="[SwiperEffectCoverflow, SwiperNavigation]"。A specific module name, you can check https://nuxt.com/modules/swiper#usage

This worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants