I am using Nuxt.js and have some dynamic routes. My folder structure is this:
- pages
- product
- _slug.vue
I link to the route like this:
<nuxt-link :to="{ name: 'product-slug', params: { slug: product.slug } }">
It works fine, it shows the correct URL and also directs the page fine, however, I am getting an annoying red error in my console:
[Vue warn]: Invalid component name: "pages/product/_slug.vue". Component names should conform to valid custom element name in html5 specification.
I have found this issue, but to little avail: https://github.com/nuxt/nuxt.js/issues/165
[Vue warn]: Invalid component name: "pages/product/_slug.vue". Component names should conform to valid custom element name in html5 specification.
Invalid component name: "pages/product/_slug.vue". Component names should conform to valid custom element name in html5 specification. #67 Invalid component name: "pages/product/_slug.vue". Component names should conform to valid custom element name in html5 specification. #67
Component names should conform to valid custom element name in html5 specification Bookmark this question. Show activity on this post. I am using Nuxt.js and have some dynamic routes.
Where you have name in your component remove the space between the name. e.g
export default {
name: 'Assign Role'
}
Change it to:
export default {
name: 'AssignRole',
}
The reason of this error message is that the name of the _slug.vue
component which is the same as the file name.
I expect it name='_slug.vue'
you need to change it to something like this name='ProductItem'
I am not sure this is a bug or what.
But after giving a name to my components, fixed this issue as follows.
export default {
name: 'NameOfTheCompnent',
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With