3

I'm getting an error when I'm trying to use custom tags like this:

<material-button>Ok</material-button>

It's not a real component, just semantic HTML with a specific CSS. However, I'm getting this Vuew error:

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

found in

Can I avoid this error without having to create and register <material-button> as a component?

Note: everything works perfectly is just that [Vue warn] that pops up in the console all the time.

4 Answers 4

3

You can use v-pre attribute on your component

<material-button v-pre> </material-button>

https://v2.vuejs.org/v2/api/#v-pre

or you can use ignoredElements

Vue.config.ignoredElements = [
    "material-button"
]

https://v2.vuejs.org/v2/api/#ignoredElements

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome Owl. Finally my HTML is more meaningful with the custom tags and I can avoid long dividities with so many classes.
0

you can check the solution here: Vue warn Failed to resolve component: ion-icon

if you want tot past and pass, update vue.config.js like


// vue.config.js
module.exports = {
  chainWebpack: config => {
    config.module
      .rule('vue')
      .use('vue-loader')
      .tap(options => {
        options.compilerOptions = {
          ...options.compilerOptions,
          isCustomElement: tag => tag.startsWith('material-')
        }
        return options
      })
  }
}

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

I solved this in my webpack config, by applying these options to the vue-loader:

  {
    test: /\.vue$/,
    loader: "vue-loader",
    options: {
      cacheBusting: false, // true by default (:
      compilerOptions: {
        isCustomElement:  (tag) => tag === "lottie-player",
      },
    },
  },

By doing this I don't get any warnings when using

<lottie-player></lottie-player>

in my components.

My setup is:

"vue": "^3.2.31",
"vue-loader": "^16.2.0",
"webpack": "^5.53.0",

Comments

0

You cannot disable warnings on a per component basis as per Linus_Borg

However you can use Vue.config.silent to suppress all warnings

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.