Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown custom element for Layout #1426

Closed
1 task done
mathieutu opened this issue Mar 11, 2019 · 7 comments
Closed
1 task done

Unknown custom element for Layout #1426

mathieutu opened this issue Mar 11, 2019 · 7 comments

Comments

@mathieutu
Copy link
Contributor

mathieutu commented Mar 11, 2019

  • I confirm that this is an issue rather than a question.

Bug report

Version

v1.0.0-alpha.44

Steps to reproduce

What is expected?

A new component in theme/layouts directory should be available as layout.

What is actually happening?

Sometimes when navigating through the app, a page is not loaded, and an "Unknown custom element" error is thrown.

It can be a custom layout or not.

The page is ok if I refresh it.

It don't know how to reproduce the bug and find a proper pattern for that.

[Vue warn]: Unknown custom element: <Tag> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
       <Root>
[Vue warn]: Unknown custom element: <v-b2bf5494> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Content>
       <Page> at node_modules/@vuepress/theme-default/components/Page.vue
         <ParentLayout> at node_modules/@vuepress/theme-default/layouts/Layout.vue
           <Layout> at .vuepress/theme/layouts/Layout.vue
             <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
               <Root>

---> <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
       <Root>
[Vue warn]: Unknown custom element: <Post> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <GlobalLayout> at node_modules/@vuepress/core/lib/client/components/GlobalLayout.vue
       <Root>

Other relevant information

I'm using the blog plugin, and it adds some layout automatically to pages.

All my Layout components have a name key.

@shigma
Copy link
Collaborator

shigma commented Mar 11, 2019

Don't use words like sometimes. You should tell us how.

If the situation you mentioned only occurs after modifying config.js, then this is a known issue.

@mathieutu
Copy link
Contributor Author

@shigma It's why it was actually emphasized, and why there is a mention:

It don't know how to reproduce the bug and find a proper pattern for that.

It was on purpose to tell you that I have no idea of the why or how. But now you told me that it can be after updating config.js, I will pay attention of that, and will be able to confirm it to you.

😉

@ulivz
Copy link
Member

ulivz commented Mar 12, 2019

A new component added in theme/layouts will not trigger reloading so your new layout will not be available, and you need to watch it by yourself or re-launch your dev server.

@ulivz ulivz closed this as completed Mar 17, 2019
@jessemarple
Copy link

In my case, the issue was simply a hanging comma in the config file. Very strange.

ulivz pushed a commit that referenced this issue Jul 20, 2019
… />` in a custom page without markdown (#1699)

**Bug**: example, , will raise `[Vue warn]: Unknown custom element`, like #1173 #1426

**Reason**: because it not inject any content in `@internal/page-components` while not find markdown file, `Vue.component` of `pageKey` must be `undefined`, then `h(pageKey)` raise this error

**Fix**: judge as `if (Vue.component(pageKey))`, unnecessary to render if no component existed
@bill-dou
Copy link

bill-dou commented Sep 9, 2022

I still can have the issue in Vuepress v1.9.7. I even tried the Vuepress docs codebase and same problem.

[Vue warn]: Unknown custom element: <v-7324b362> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

@krofax
Copy link

krofax commented Dec 2, 2022

@bill-dou have you gotten some help on this?

@bill-dou
Copy link

bill-dou commented Dec 2, 2022

@krofax yes, I got a solution.

EnhanceApp.js

import pageComponents from '@internal/page-components'

export default ({ Vue }) => {
  for (const [name, component] of Object.entries(pageComponents)) {
    Vue.component(name, component)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants