mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): warn if inheritAttrs: false
when using useId
(#25616)
This commit is contained in:
parent
b78e1cb206
commit
8705aed8b4
@ -29,6 +29,9 @@ export function useId (key?: string): string {
|
|||||||
const instanceIndex = key + ':' + instance._nuxtIdIndex[key]++
|
const instanceIndex = key + ':' + instance._nuxtIdIndex[key]++
|
||||||
|
|
||||||
if (import.meta.server) {
|
if (import.meta.server) {
|
||||||
|
if (import.meta.dev && instance.vnode.type && typeof instance.vnode.type === 'object' && 'inheritAttrs' in instance.vnode.type && instance.vnode.type.inheritAttrs === false) {
|
||||||
|
console.warn('[nuxt] `useId` is not compatible with components that have `inheritAttrs: false`.')
|
||||||
|
}
|
||||||
const ids = JSON.parse(instance.attrs[ATTR_KEY] as string | undefined || '{}')
|
const ids = JSON.parse(instance.attrs[ATTR_KEY] as string | undefined || '{}')
|
||||||
ids[instanceIndex] = key + ':' + nuxtApp._id++
|
ids[instanceIndex] = key + ':' + nuxtApp._id++
|
||||||
instance.attrs[ATTR_KEY] = JSON.stringify(ids)
|
instance.attrs[ATTR_KEY] = JSON.stringify(ids)
|
||||||
|
Loading…
Reference in New Issue
Block a user