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 - <v-#####> #1173

Closed
1 task done
bretterer opened this issue Jan 7, 2019 · 23 comments
Closed
1 task done

Unknown Custom Element - <v-#####> #1173

bretterer opened this issue Jan 7, 2019 · 23 comments

Comments

@bretterer
Copy link
Contributor

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

Bug report

During development, we created a component that went through each index.md file in a folder based on the this.$site.pages.path list. After upgrading to 1.0.0-alpha.30 to fix a few other issues we were having, It no longer works.

Component code:

<template>
  <div>
    <Content v-for="page in changelogPages" :key="page.key" :pageKey="page.key"/>
  </div>
</template>

<script>
import _ from "lodash"
export default {
  computed: {
    changelogPages: function () {
      let pages = this.$site.pages
        .filter(pages => pages.path.startsWith("/docs/change-log/2"))

      return _.orderBy(pages, 'path').reverse()
    }
  },
  data: function () {
    return {}
  }
}

</script>

This results in the following errors.
screen shot 2019-01-07 at 5 39 58 pm

looking at the Vue plugin for chrome, I can see that the page.key is there.

screen shot 2019-01-07 at 5 39 29 pm

In the page, I am simply calling <ChangeLogList /> which invokes the above global-component.

Reference Links in repo

Global Component : https://github.com/okta/okta.github.io/blob/VuePress/packages/%40okta/vuepress-theme-default/global-components/ChangeLogList.vue

Component invoking ChangeLogList:https://github.com/okta/okta.github.io/blob/VuePress/packages/%40okta/vuepress-theme-default/components/ChangeLog.vue

Page that is uisng ChangeLog (View Raw): https://github.com/okta/okta.github.io/blob/VuePress/packages/%40okta/vuepress-site/docs/change-log/index.md

Version

1.0.0-alpha.30

Steps to reproduce

See Repo (and branch VuePress) https://github.com/okta/okta.github.io/tree/VuePress

What is expected?

Display inline the content of each changelog file

What is actually happening?

Throwing console errors

Other relevant information

  • Your OS: Mac OS
  • Node.js version: 11.6.0
  • Browser version: 71.0.3578.98
  • Is this a global or local install? Local
  • Which package manager did you use for the install? Yarn
@cietho
Copy link

cietho commented Feb 24, 2019

Hi @bretterer,
did you try this.$site.pages.regularPath instead of this.$site.pages.path. This works for me :)

@bretterer
Copy link
Contributor Author

@cietho same issue. I am getting the correct key for the page, so I don't think that is the issue? Have you tried it with the linked code above?

@bretterer
Copy link
Contributor Author

@ulivz @yyx990803 Trying to get some attention on this. It seems to have regressed into a broken version of being able to use pageKey

This is preventing a major part of our new site being built. Any way to get some attention to this bug? I am not sure if this was caused by the changes inside of VuePress, or if this is actually vue.js related.

@meteorlxy
Copy link
Member

Suggest to test in the newest version and update the issue.

cc @shigma and you will get quicker response.

@ulivz
Copy link
Member

ulivz commented Mar 2, 2019

@bretterer If you want others to help you, please follow the issue guidelines, and create a minimal and valid repro repo since it's so large for me to clone.

@meteorlxy
Copy link
Member

meteorlxy commented Mar 3, 2019

I found a similar issue related to this.

The cause is that we do not register all the layout-components and page-components autoly. Only when we are trying to enter the corresponding route will we register the component via ensureAsyncComponentsLoaded.

ensureAsyncComponentsLoaded(${JSON.stringify(layout || 'Layout')}, ${JSON.stringify(componentName)}).then(next)

So if you are using <Content v-for="page in changelogPages"/> in the same page / route, the page components are not registered.

@bretterer
Copy link
Contributor Author

@ulivz @meteorlxy @shigma

Reproduction Repo added.

https://github.com/bretterer/VuePress-bug-1173

Just run the yarn install and yarn dev command and you will see the error

@meteorlxy
Copy link
Member

@bretterer This will be fixed if #1402 is merged

@davision
Copy link

davision commented Mar 7, 2019

I just stumble upon the same issue. I'm running version 1.0.0-alpha.42. As a consequence, the links from sidebar doesn't load the page. It appears only after the page is refreshed. Any quick fix I can make?

@meteorlxy
Copy link
Member

meteorlxy commented Mar 7, 2019

@davision

A quick fix for this issue in enhanceApp.js (for 1.0.0-alpha.42):

import pageComponents from '@internal/page-components'

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

This will (I think) fix all similar issues with Unknown Custom Element - <v-#####>, as we have already registered all the <v-#####> components.

What's more, all these components are async components, so you might not worry much about the registeration.

@davision
Copy link

davision commented Mar 7, 2019

Awesome, that worked as a cham. I figured out that this issue only happens when using custom components. Which this enhancement fixes. Thank you very much!

bretterer added a commit to okta/okta-developer-docs that referenced this issue Mar 7, 2019
This registers all the components into Vue.  This ia a temp fix until github.com/vuejs/vuepress/issues/1173 is patched
bretterer added a commit to okta/okta-developer-docs that referenced this issue Mar 7, 2019
This registers all the components into Vue.  This ia a temp fix until github.com/vuejs/vuepress/issues/1173 is patched
@ulivz
Copy link
Member

ulivz commented Mar 9, 2019

The workaround from @meteorlxy isn't a good idea.

The page component should be registered ONLY when they are used, otherwise and you’ll be switched to a new page even if your content of asynchronous page has not been loaded - this experience is too strange, besides, the current state of nprogress is wrong.

@ulivz ulivz closed this as completed in 9d01514 Mar 9, 2019
@ulivz
Copy link
Member

ulivz commented Mar 9, 2019

Accurately fixed at 9d01514 and out at 1.0.0-alpha.43.

@davision
Copy link

Hmm, looks like not really or I'm having different problem with this issue. I'm still getting an error, when I'm using a custom vue component, on index.md, and click to another link: Unknown custom element: <v-88235c4e>

@ITsolution-git
Copy link

Is there any upadate on this issue please?
@davision were you able to fix that problem? It loads properly on first reload, but when I click on another page, it just gives me the same error.

@davision
Copy link

Hey, looks like it is solved for me yes with hack from @meteorlxy. Even running the latest alpha version should work fine.

@antonreshetov
Copy link

antonreshetov commented May 15, 2019

Same error in 1.0.0-alpha.48
@meteorlxy thanks for solution!

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
wallslide added a commit to appsocially/upil-site that referenced this issue Sep 12, 2019
@justin-schroeder
Copy link

I'm on 1.2.0 and still experiencing this issue, but the @meteorlxy works for me. I realize it's not ideal, but I don't see another alternative at this point?

@tianjianchn
Copy link

@justin-schroeder Same as me, 1.2.0 and @meteorlxy 's hacking enhanceApp.js working. After dig it, I find that if changing

if (Vue.component(pageKey)) {
return h(pageKey)
}

return h(pageKey) -> return h(Vue.component(pageKey)), all will be fine without the hacking above. Hope that can help some.

@meteorlxy
Copy link
Member

@justin-schroeder @tianjianchn

What about creating a new issue to report / suggest that?

Providing a reproduction repo could help a lot.

@psi-4ward
Copy link
Contributor

Indeed, same here

@zhixinpeng
Copy link

same here, 1.2.0

@meteorlxy
Copy link
Member

In current version, the cause of Unknown Custom Element - <v-#####> could be different from the original issue.

If anyone still meet with this problem, please open another issue and provide the reproduction steps / repo.

@vuejs vuejs locked and limited conversation to collaborators Jan 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests