NUXT_B3014

服务器组件上的事件监听器

Maschinelle Übersetzung ·0 % geprüft

B3014

模板在服务器组件上使用了 v-on(或 @)或 v-model。服务器组件只在服务器端渲染,自身不会发送 JavaScript,因此不会触发事件,也无法更新 v-model 绑定。该监听器永远不会被调用。

除非禁用了 experimental.templateDiagnostics,否则会报告此警告。@error 不会触发此警告:服务器组件加载失败时会触发 error。

解决方案

在客户端渲染交互部分。你可以为服务器组件配对一个同名的 .client.vue 组件,使用 nuxt-client 属性渲染交互式子组件(需启用 experimental.componentIslands.selectiveClient),或者将监听器移到包裹服务器组件的客户端组件中。

app/components/Counter.server.vue
<template>
  <div>
    <!-- auf dem Server gerendert, dann auf dem Client hydratisiert -->
    <CounterButton nuxt-client />
  </div>
</template>
Weitere Informationen findest du unter Docs > Guide > Concepts > Server Components.

Was this helpful?