将 StencilJS 组件与另一个 StencilJS 组件一起使用
Using StencilJS components with another StencilJS component
我的一般问题是,如何在另一个模板组件中使用模板构建组件。不在 PWA 工具包中,而是在另一个组件中。
更具体地说,我想使用的组件不在 npm 上,而是在私有 bitbucket 存储库上。在其 package.json 中有准备脚本 ("prepare":"stencil build"
)。然后,我使用 git link 将组件添加到 package.json 中的父组件。当我 运行 npm install child-component
时,它从 bitbucket 中获取组件并使用 prepare
脚本构建它。这工作正常。但是我如何添加一个组件 loaded/rendered?
要渲染导入的组件,您必须在根组件中执行此操作:
render(){
[<imported-child-component />, ...];
return(<the-root-components-html />);
}
之后,您可以在应用中的任何地方使用 imported-child-component。
我的一般问题是,如何在另一个模板组件中使用模板构建组件。不在 PWA 工具包中,而是在另一个组件中。
更具体地说,我想使用的组件不在 npm 上,而是在私有 bitbucket 存储库上。在其 package.json 中有准备脚本 ("prepare":"stencil build"
)。然后,我使用 git link 将组件添加到 package.json 中的父组件。当我 运行 npm install child-component
时,它从 bitbucket 中获取组件并使用 prepare
脚本构建它。这工作正常。但是我如何添加一个组件 loaded/rendered?
要渲染导入的组件,您必须在根组件中执行此操作:
render(){
[<imported-child-component />, ...];
return(<the-root-components-html />);
}
之后,您可以在应用中的任何地方使用 imported-child-component。