mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
fix(nuxt): improve warning for invalid children of <Title>
(#21613)
This commit is contained in:
parent
64bccf37a5
commit
634829a08c
@ -149,12 +149,20 @@ export const Title = defineComponent({
|
|||||||
name: 'Title',
|
name: 'Title',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
setup: setupForUseMeta((_, { slots }) => {
|
setup: setupForUseMeta((_, { slots }) => {
|
||||||
const title = slots.default?.()?.[0]?.children || null
|
if (process.dev) {
|
||||||
if (process.dev && title && typeof title !== 'string') {
|
const defaultSlot = slots.default?.()
|
||||||
console.error('<Title> can only take a string in its default slot.')
|
|
||||||
|
if (defaultSlot && (defaultSlot.length > 1 || typeof defaultSlot[0].children !== 'string')) {
|
||||||
|
console.error('<Title> can take only one string in its default slot.')
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title
|
title: defaultSlot?.[0]?.children || null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: slots.default?.()?.[0]?.children || null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user