Failed resolve component in <custom-element> inside <custom-element>
Version
3.2.11
Reproduction link
Steps to reproduce
- Define 2 custom element
- Embed one into the other
What is expected?
render components
What is actually happening?
render component is complete, but in console
[Vue warn]: Failed to resolve component: test-case-inside
at <App >
Yes, I tried to use it as
const App = Vue.createApp({});
App.config.compilerOptions.isCustomElement = tag => tag === 'test-case-inside';
but it not work. Add compilerOptions in attached CodePan
Ah ok, you are nesting one custom element in another.
Since custom elements are registered globally and not under a normal Vue app, configuring an app instance has no effects on them. You need to pass the compilerOptions
inline:
customElements.define(
'test-case',
Vue.defineCustomElement({
compilerOptions: {
isCustomElement: tag => tag.startsWith('test-')
},
template: `<test-case-inside></test-case-inside>`
})
)
You'll probably want this for all elements you define if you intend to nest them in one another - you can create a convenience function that wraps the the all the define calls for easier element creation.