“Unknown custom element” warning inside a component tag, but not outside of it

为君一笑 提交于 2019-12-04 06:19:09

This is because you are using the inline-template special attribute on the <social-sharing> component.

From the documentation:

When the inline-template special attribute is present on a child component, the component will use its inner content as its template, rather than treating it as distributed content.

Everything inside the <social-sharing> tag is being treated as if it were the template definition for that component. And, since your <icon> component is being registered outside the <social-sharing> component's scope, it doesn't know what to do with the <icon> tag.

Since it looks like the <social-sharing> component is dependant on an inline-template definition, the only thing I can think to do is register the <icon> component globally:

// in your main.js file
import Icon from '~/comps/icon.vue'
Vue.component('Icon', Icon);

Then, since the <icon> component will be in the global scope, the <social-sharing> component will have a reference to it.

I simply forgot to close a script tag in my component.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!