无法将 StencilJS 与 .net 核心 mvc 一起使用
Unable to use StencilJS with .net core mvc
我是 StencilJS 的新手,我有一个编译的自定义组件,我想在 .Net Core MVC 中使用它。我在我的 _Layout 中添加 JavaScript,如下所示:
<script type="module" src="~/js/customui.esm.js"> and <script nomodule src="~/js/customui.js">
然后我添加我的自定义组件标签
<my-buttom></my-button>
然而,屏幕上没有任何内容。在我的组件渲染中我有:
<host class={'myButtonTheme'}>Test render</host>
我不确定我做错了什么。我将 StencilJS 配置设置为默认输出。
我认为错误在于您使用的是 <host>
。 Host
(大写)是从@stencil/core
导出的功能组件,你必须像
一样使用它
import { Component, Host, h } from '@stencil/core';
@Component({ tag: 'my-button' })
export class MyButton {
render() {
return <Host class="myButtonTheme">Test render</Host>;
}
}
<host></host>
作为标签将是原生 HTML 元素(因为自定义元素需要名称中的破折号)但规范中不存在此类元素。
我是 StencilJS 的新手,我有一个编译的自定义组件,我想在 .Net Core MVC 中使用它。我在我的 _Layout 中添加 JavaScript,如下所示:
<script type="module" src="~/js/customui.esm.js"> and <script nomodule src="~/js/customui.js">
然后我添加我的自定义组件标签
<my-buttom></my-button>
然而,屏幕上没有任何内容。在我的组件渲染中我有:
<host class={'myButtonTheme'}>Test render</host>
我不确定我做错了什么。我将 StencilJS 配置设置为默认输出。
我认为错误在于您使用的是 <host>
。 Host
(大写)是从@stencil/core
导出的功能组件,你必须像
import { Component, Host, h } from '@stencil/core';
@Component({ tag: 'my-button' })
export class MyButton {
render() {
return <Host class="myButtonTheme">Test render</Host>;
}
}
<host></host>
作为标签将是原生 HTML 元素(因为自定义元素需要名称中的破折号)但规范中不存在此类元素。