Nuxt.js: layouts and double initialize component

Created on 2 Nov 2017  路  15Comments  路  Source: nuxt/nuxt.js

Hi!
I use latest nuxt and i have problem with double initialize component which rendering in layout .
I have layout named "main" and default route ("/") which must rendered in the "main layouts" using component "logreg.vue".
When default route rendering i see 3 initialization logreg.vue component.
screen shot 2017-11-02 at 22 21 32
layouts/main.vue
screen shot 2017-11-02 at 22 26 33
pages/index.vue
screen shot 2017-11-02 at 22 27 32
result after loading page
screen shot 2017-11-02 at 22 32 50
nuxt.config.js
Sorry for concern but did not find a solution to this problem

This bug report is available on Nuxt.js community (#c1788)
available soon bug-confirmed

All 15 comments

Would you mind offering a demo repo, so that we can reproduce the issue ?

sorry, I didn't reproduce this issue, following is the steps:

image
image

If I missed anything, pls let me know 馃槃

Sorry i do not know what i am doing wrong ... I reinstalled all node_modules.
Can you give me your nuxt.config.js?

First my error (nuxt-child) was in the main layout, i remove (nuxt-child) and see only 2 created log.
screen shot 2017-11-05 at 12 01 45

Then i comented (mode: 'spa') in nuxt.config.js
screen shot 2017-11-05 at 12 02 57

and see only 1 initialization .
screen shot 2017-11-05 at 12 10 05

Is it possible to use a SPA mode with a layout?

I didn't change anything in you nuxt.config.js.
Did your local codes are different from github ?
Because your github code's layout is not main.

Did your local codes are different from github ? No. Same code from ( https://github.com/Gimanh/handscream_front/tree/nuxt/web/hsnuxt )

Because your github code's layout is not main. What do you mean?

Here is video https://www.youtube.com/watch?v=Y8VD38WHe0g&feature=youtu.be :)

Because your github code's layout is not main. What do you mean?

I cloned the repo yesterday, but didn't find layout: 'main', I will update the repo and try again

@Gimanh
I updated the codes and reproduced the issue, this issue has been fixed in https://github.com/nuxt/nuxt.js/commit/9e4f864e4d25af2e9668767bb297182656e19cba and will be available in next rc release.
Thank you for your time and patient assistance馃樃

BTW, if you want to make a verification or quick fix, you man delete or comment fixPrepatch.call row in .nuxt/client.js: render.call as the commit I mentioned above did.

    if (!path) {
      normalizeComponents(router.currentRoute, router.currentRoute)
      // fixPrepatch.call(_app, router.currentRoute, router.currentRoute)
      mountApp()
      return
    }

Thanks for the help and for NUXT! :)

Sorry :) But this
if (!path) {
normalizeComponents(router.currentRoute, router.currentRoute)
// fixPrepatch.call(_app, router.currentRoute, router.currentRoute)
mountApp()
return
}
is help if i commented (mode: "spa")
I recorded a video with a situation
https://www.youtube.com/watch?v=1rPwJwB85-w&feature=youtu.be

This is related to https://github.com/nuxt/nuxt.js/issues/1929, will also be fixed in next release.

clarkdo thanks, i will wait next release! Have a good day!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maicong picture maicong  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments

uptownhr picture uptownhr  路  3Comments

VincentLoy picture VincentLoy  路  3Comments

msudgh picture msudgh  路  3Comments