Skip to content

Commit b82f8d1

Browse files
authored
fix: set default name to layout to avoid multi mounted (nuxt#7128)
1 parent 90c6922 commit b82f8d1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/vue-app/template/App.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
getMatchedComponentsInstances,
55
getChildrenComponentInstancesUsingFetch,
66
promisify,
7-
globalHandleError
7+
globalHandleError,
8+
sanitizeComponent
89
} from './utils'
910
<% } %>
1011
<% if (features.layouts && components.ErrorPage) { %>import NuxtError from '<%= components.ErrorPage %>'<% } %>
@@ -23,7 +24,7 @@ import '<%= relativeToBuild(resolvePath(c.src || c, { isStyle: true })) %>'
2324
}
2425
}).join('\n') %>
2526

26-
const layouts = { <%= Object.keys(layouts).map(key => `"_${key}": _${hash(key)}`).join(',') %> }<%= isTest ? '// eslint-disable-line' : '' %>
27+
const layouts = { <%= Object.keys(layouts).map(key => `"_${key}": sanitizeComponent(_${hash(key)})`).join(',') %> }<%= isTest ? '// eslint-disable-line' : '' %>
2728

2829
<% if (splitChunks.layouts) { %>let resolvedLayouts = {}<% } %>
2930
<% } %>

packages/vue-app/template/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function sanitizeComponent (Component) {
8080
Component._Ctor = Component
8181
Component.extendOptions = Component.options
8282
}
83-
// For debugging purpose
83+
// If no component name defined, set file path as name, (also fixes #5703)
8484
if (!Component.options.name && Component.options.__file) {
8585
Component.options.name = Component.options.__file
8686
}

0 commit comments

Comments
 (0)