Is the "name" attribute required in (certain) single file components? #9655
-
While working with layout components today I noticed a warning in the console every time I am routed to my layout page:
This doesn't appear on initial page load, only on subsequent routings to the page (in SSR dev mode). The layout works perfectly fine. After googling this problem I found 2 similar questions on stackoverflow with identical answers:
The answers in both threads say to add the "name" property to the component causing the warning but without a reason why that fixes it. I couldn't find anything about this in the Nuxt docs so it looks to me like a bug? Any explanation would be welcome. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
What is the name you wrote? |
Beta Was this translation helpful? Give feedback.
-
This is due to the automated name generation from Nuxt which simply takes the path of the component. You can add a name on your own which will overwrite the "faulty" name and, as long as that one matches, the warning will disappear. |
Beta Was this translation helpful? Give feedback.
This is due to the automated name generation from Nuxt which simply takes the path of the component.
In theory this shouldn't create any problems except the warning in dev. The warning basically says that the name is not in line with the W3C spec for custom elements (see vuejs/vue#11204 (comment) and the specs).
You can add a name on your own which will overwrite the "faulty" name and, as long as that one matches, the warning will disappear.