Skip to content

await with layoutTransition and pageTransition mounted executed twice In a different layout - nuxt 3 #27364

@anas-js

Description

@anas-js

Update

The problem was reported more than two months ago!!

Environment


  • Operating System: Windows_NT
  • Node Version: v20.11.1
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: npm@10.8.0
  • Builder: -
  • User Config: experimental, hooks, ssr, devtools, nitro, vite, css, pwa, spaLoadingTemplate, app, modules, eslint, i18n
  • Runtime Modules: @nuxtjs/i18n@8.3.1, @pinia/nuxt@0.5.1, @nuxt/eslint@0.3.10, @hypernym/nuxt-anime@2.1.1, @vite-pwa/nuxt@0.7.0
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-bv3yea?file=pages%2Findex.vue

Describe the bug

In my application layoutTransition and pageTransition through nuxt.config.ts I have:

  app: {
    layoutTransition: {
      name: 'layout',
      mode: 'out-in',
      appear: true,
    },

    pageTransition: {
      name: 'page-trans',
      mode: 'out-in',
      appear: true,
    },
  },

I have 2 layout they are :

  • default.vue
  • tow.vue

And pages:

  • index.vue (set default layout)
  • about.vue (set tow layout)

When I do await $fetch on the about.vue page, the onMounted is executed twice, whether on the page itself or in the components in it..

This happens when moving from the index page to about. However, when you enter this page directly, the problem does not appear.

router.push('/about') 

--------- or --------

<NuxtLink to="/about">go to /about</NuxtLink>

You can view the project here :
https://stackblitz.com/edit/github-bv3yea?file=pages%2Findex.vue

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions