primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
9.47k stars 1.14k forks source link

Failed to resolve component and Component <Anonymous> is missing template or render function. #5716

Open andreLuis1506 opened 3 months ago

andreLuis1506 commented 3 months ago

Describe the bug

i use nuxt and primevue v4, How to resolve this error: [Vue warn]: Failed to resolve component: ui-button If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.

Plugins/primevue.client.ts:
import Button from "primevue/button/"
export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(PrimeVue, {
    theme: {
      preset: myPreset,
    }
  })

  nuxtApp.vueApp.component('UiButton', Button)
})

Component usage: The component appears normally on the screen, and all props work, but this error appears in the terminal and the IDE does not offer any auto complite for the component Some help?

Reproducer

https://github.com/andreLuis1506/teste

PrimeVue version

4.0.0-beta-2

Vue version

3.x

Language

TypeScript

Build / Runtime

Nuxt

Browser(s)

No response

Steps to reproduce the behavior

start the server with yarn dev enter in localhost:3000 The erro will the error will appear in the terminal

Expected behavior

No response

andreLuis1506 commented 3 months ago

I managed to solve the autocomplete by following this recommendation: https://github.com/nuxt/nuxt/issues/25371

Basically I added this code at the end of the plugin:

declare module 'vue' {
  interface GlobalComponents {
    FontAwesomeIcon: typeof FontAwesomeIcon
  }
}

But this warning keeps appearing: [Vue warn]: Failed to resolve component: ui-button If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.