使用自定义标签时避免 Vue 警告 [英] Avoid Vue warn when using custom tags

查看:77
本文介绍了使用自定义标签时避免 Vue 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用这样的自定义标签时出现错误:

确定

它不是真正的组件,只是具有特定 CSS 的语义 HTML.但是,我收到了这个 Vuew 错误:

 [Vue warn]:未知的自定义元素:- 您是否正确注册了组件?对于递归组件,请确保提供名称"选项.在发现

我可以在不必创建和注册 作为组件的情况下避免这个错误吗?

注意:一切正常,只是控制台中一直弹出[Vue警告].

解决方案

您可以在组件上使用 v-pre 属性

</material-button>

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

或者你可以使用 ignoredElements

Vue.config.ignoredElements = [材料按钮"]

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

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.

解决方案

You can use v-pre attribute on your component

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

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

or you can use ignoredElements

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

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

这篇关于使用自定义标签时避免 Vue 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆