【发布时间】:2018-01-27 10:37:50
【问题描述】:
我在 Stencil 的官方文档中找到了这些片段。
我无法理解在 my-parent-component 中如何访问 my-embedded-component 不提供子组件的路径。谁能帮我理解这个概念?
子组件
import { Component, Prop } from '@stencil/core';
@Component({
tag: 'my-embedded-component'
})
export class MyEmbeddedComponent {
@Prop() color: string = 'blue';
render() {
return (
<div>My favorite color is {this.color}</div>
);
}
}
父组件
import { Component } from '@stencil/core';
@Component({
tag: 'my-parent-component'
})
export class MyParentComponent {
render() {
return (
<div>
<my-embedded-component color="red"></my-embedded-component>
</div>
);
}
}
【问题讨论】:
标签: javascript stenciljs