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

In the NuxT3 project, the Autoplay of swiper.js becomes invalid after the route is switched #14464

Closed
qyn980427 opened this issue Jul 30, 2022 · 9 comments

Comments

@qyn980427
Copy link

Environment


  • Operating System: Windows_NT
  • Node Version: v14.17.5
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: npm@6.14.14
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/qyn980427/nuxt3Test

Describe the bug

When I was using Swiper.js and Swiper of Vant component library in my own project, I encountered the problem of Autoplay failure after route switch. At first I thought it was my problem, but later I felt that it might not be my problem.   Autoplay will become invalid after the route is jumped back

Additional context

Repetition steps

1.When you enter Index for the first time, Swiper is normal
2. On index, use nuxtlink to access the test page
3. On the test page, use nuxtlink to return to the Index page
4.The Autoplay of swiper is invalid

Logs

No response

@danielroe
Copy link
Member

Would you try to reproduce via https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter/tree/main ?

@qyn980427
Copy link
Author

Would you try to reproduce via https://stackblitz.com/github/nuxt-contrib/vue3-ssr-starter/tree/main ?

I've tried it and it's fine on this one, but why is the problem I've described happening on NUXT3?

@ikexing-cn
Copy link

+1,I have the same problem.

@qyn980427
Copy link
Author

Hello, what is wrong with this demo https://stackblitz.com/edit/nuxt-starter-txwyvc

@danielroe
Copy link
Member

Yes, it does seem to reproduce only on Nuxt - I asked you to try that other vue3 only repro to confirm - and for future reference, https://stackblitz.com/edit/github-midbdm.

I think the cause might be #13471 (which is an upstream vue issue that reproduces only with the current configuration), but I haven't dived into the swiper codebase to confirm...

@ikexing-cn
Copy link

A solution, as seen in #13471
Set <NuxtPage :key="$route.fullPath" /> in your app.vue file and everything works.

@danielroe
Copy link
Member

Great. Then I think we can follow this issue there.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2022
@AnatoliiDev
Copy link

A solution, as seen in #13471 Set <NuxtPage :key="$route.fullPath" /> in your app.vue file and everything works.

This is not optimal. And in this case you have problem with full reload page after add querry params to url.

@ikexing-cn
Copy link

This is not optimal. And in this case you have problem with full reload page after add querry params to url.

You can absolutely judge some query params once and have it not reload.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants