hybrids components

src/my.counter.ts:

import { type Component, define, html } from "hybrids";

interface MyCounter {
  count: number;
}

function increaseCount(host: MyCounter) {
  host.count += 1;
}

const MyCounter: Component<MyCounter> = {
  tag: "my-counter",
  count: 0,
  render: {
    shadow: true,
    value: ({ count }) => html`
    <button onclick="${increaseCount}">
      Count: ${count}
    </button>
  `,
  }
}

export default define(MyCounter);

只能用vite编译,bun编译后的代码运行出错,stack超过最大值,parcel不能编译。

posted @ 2024-08-21 11:05  卓能文  阅读(6)  评论(0编辑  收藏  举报