[英]Polymer 3 custom element within a custom element template
I have two components: A and B. I want to use within As template getter a custom element which I import via regular import statement, example: 我有两个组件:A和B。我想在As模板getter中使用通过常规import语句导入的自定义元素,例如:
import {LitElement, html} from '@polymer/lit-element';
import B from "./b-element";
export class A extends LitElement {
...
render() {
return html`Here comes the element <b-element></b-element>`;
}
}
customElements.define('a-element', A);
Element B: 元素B:
import {LitElement, html} from '@polymer/lit-element';
export class B extends LitElement {
...
render() {
return html`Hello Component B here!`;
}
}
customElements.define('b-element', B);
Now of course I want to embed A somewhere else. 现在,我当然想在其他位置嵌入A。
However b-element
is not recognized although module B has a call to customElements.define(...)
, which seems not to cause it being recognized at this point. 但是,尽管模块B调用了
customElements.define(...)
,但无法识别b-element
,这似乎并未导致此时识别它。
This works, I noticed that the custom element name was invalid in my actual code! 这可行,我注意到自定义元素名称在我的实际代码中无效! Don't forget to define the custom-element name
in-the-specification
way! 不要忘记以
in-the-specification
方式定义自定义元素的名称!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.