Skip to content

Default layout and code-splitting #1998

Answered by drfcozapata
beard7 asked this question in Help (Vue)
Discussion options

You must be logged in to vote

Ok. The problem you have occurs because the object 'page' you are trying to modify is 'undefined'. This happens if the import of the component has not been resolved correctly.
When you use 'eager: false', 'page' becomes a promise, and you need to wait for it to resolve before trying to access its properties. Here is a way to fix your code:

resolve: async name => {
    const pages = import.meta.glob('./Pages/**/*.vue', { eager: false });
    let page = await pages[`./Pages/${name}.vue`]();
    page.default.layout = name.startsWith('Auth/') ? undefined : AppLayout;
    return page;
}

That code should help you solve the problem. I hope it helps.

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@beard7
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@beard7
Comment options

@drfcozapata
Comment options

Answer selected by beard7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants