问题描述
限时送ChatGPT账号..当我尝试使用这样的自定义标签时出现错误:
它不是真正的组件,只是具有特定 CSS 的语义 HTML.但是,我收到了这个 Vuew 错误:
[Vue warn]:未知的自定义元素:- 您是否正确注册了组件?对于递归组件,请确保提供名称"选项.在发现
我可以在不必创建和注册
作为组件的情况下避免这个错误吗?
注意:一切正常,只是控制台中一直弹出[Vue警告].
解决方案您可以在组件上使用 v-pre
属性
</material-button>
https://vuejs/v2/api/#v-pre一个>
或者你可以使用 ignoredElements
Vue.config.ignoredElements = [材料按钮"]
https://vuejs/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/v2/api/#v-pre
or you can use ignoredElements
Vue.config.ignoredElements = [
"material-button"
]
https://vuejs/v2/api/#ignoredElements
这篇关于使用自定义标签时避免 Vue 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论