[英]StencilJs component not render in another stenciljs project
我已经使用入门项目创建了一个 stenciljs webcomponents,我正试图通过package.json
dependecy 将它放到另一个 stenciljs 项目中,它指向一个 git 存储库。
Web 组件已导入,但当我尝试在 tsx stenciljs 项目中运行该组件时,我注意到以下内容:
.svgs
推入.tsx
文件到 return 语句中,即使在页面上添加字符后,这些图标仍然不呈现不确定我是否在这里做错了什么,奇怪的是,只要我在页面上添加其他内容,除了那个 web 组件,它就会正确呈现。
我通过以下方式将 webcomponent 导入到 stenciljs 项目中的组件中:
import 'my-component-from-git'
<-- 指向 node_modules 文件夹中的 webcomponent 文件夹
stenciljs web组件配置:
plugins: [
sass()
],
namespace: 'my-component',
outputTargets: [
{
type: 'dist',
esmLoaderPath: '../loader',
},
{
type: 'dist-custom-elements-bundle',
},
{
type: 'docs-readme',
},
{
type: 'www',
serviceWorker: null, // disable service workers
},
],
stenciljs 项目配置:
globalStyle: 'src/global/app.css',
globalScript: 'src/global/app.ts',
taskQueue: 'async',
plugins: [
sass()
],
outputTargets: [
{
type: 'www',
// comment the following line to disable service workers in production
serviceWorker: null,
baseUrl: './../',
},
],
经过一些调查,我想导出为 webcomponent 的组件使用多个functional components
来呈现其内容(对于.svgs
也是如此),在删除这些组件并在导出 webcomponent 的 class 中使用它们后,它工作正常。
我不确定这些是否有问题,或者它没有得到正确支持,或者dist
output 在使用functional components
时没有正确生成。
目前,如果有人在尝试将 stencil 生成的 webcomponent 导入另一个 stencil 项目时遇到一些奇怪的渲染问题,请尝试修改一下您的代码,使其不使用这些functional components
。
也许 Web 组件缺少某些配置的特定内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.