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

[Bug] The classname of the page does not change based on the route #27

Open
Ice-Hazymoon opened this issue Mar 9, 2023 · 1 comment

Comments

@Ice-Hazymoon
Copy link

Bug

I'm having a serious bug where the classname of a page doesn't change based on the route

image

On the /about page, the class name should be about-page, but it is index-page

about.vue

<template>
  <div class="about-page">
    <div>Nuxt Vite PWA</div>
    <NuxtLink to="/">
      Home 1
    </NuxtLink>
  </div>
</template>

index.vue

<template>
  <div class="index-page">
    <div>Nuxt Vite PWA</div>
    <NuxtLink to="/about">
      About
    </NuxtLink>
  </div>
</template>

Other

No matter what page I visit, the result is always the content of the index page. Is this normal?

image

@RifatMahmudno-1
Copy link

I've faced similar issue. This module caches the index file. So, if you try to go to other routes, it dynamically updates the content from that index page.
This problem only occurs in SSR websites. Because in SSR your index page is fully rendered unlike spa where your page is rendered in the client side.
In your case you were supposed to deliver fully rendered /about page. Instead, you're delivering '/' page. Which causes this problem.

I solved this problem by assigning a key in NuxtPage or it's container and changing the key if the page isn't / page. This will clientside render the correct page.
You can also solve it by catching all the routes.

I hope the devs will solve this problem.

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

2 participants