简中文档

fresh-server-event-handlers

NOTE: this rule is part of the fresh rule set.
Enable full set in deno.json:
{
  "lint": {
    "rules": {
      "tags": ["fresh"]
    }
  }
}
Enable full set using the Deno CLI:
deno lint --rules-tags=fresh
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{
  "lint": {
    "rules": {
      "include": ["fresh-server-event-handlers"],
      "exclude": ["fresh-server-event-handlers"]
    }
  }
}

不允许在 fresh 服务器组件中使用事件处理程序。

在 fresh 应用中的 routes/ 文件夹内的组件仅在服务器上渲染。 它们不会在客户端渲染,设置事件处理程序将没有效果。

请注意,这条规则仅适用于 routes/ 文件夹内的服务器组件,而不适用于 fresh 岛屿或任何其他组件。

无效:

<button onClick={() => {}} />
<button onclick={() => {}} />
<my-custom-element foo={() => {}} />

有效:

<button />
<my-custom-element />

你找到了你需要的东西吗?

编辑此页面
隐私政策