Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid component name: "pages/product/_slug.vue". Component names should conform to valid custom element name in html5 specification

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.

enter image description here

I have found this issue, but to little avail: https://github.com/nuxt/nuxt.js/issues/165

like image 308
FooBar Avatar asked Feb 11 '20 12:02

FooBar


People also ask

What is an invalid component name in Vue?

[Vue warn]: Invalid component name: "pages/product/_slug.vue". Component names should conform to valid custom element name in html5 specification.

Is the component name invalid 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

Should component names conform to valid custom element name in HTML5?

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.


3 Answers

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',
}
like image 198
Ghost Of Winterfell Avatar answered Oct 04 '22 18:10

Ghost Of Winterfell


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'

like image 5
Ya Basha Avatar answered Oct 04 '22 17:10

Ya Basha


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',
    ...
  }
like image 4
zarpio Avatar answered Oct 04 '22 17:10

zarpio