如何清除插件 svelte: A11y: on:blur error/warning?

how do I clear the Plugin svelte: A11y: on:blur error/warning?

如果我像这样设置 <select> 控件,那就更苗条了:

<select bind:value={selected} on:change="{() => changeTheme()}">

更改事件正确触发并且值已绑定,但我在 vscode 中收到警告:

(!) Plugin svelte: A11y: on:blur must be used instead of on:change, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users.

如果我按照描述将绑定更改为 on:blur,只有当您在创建 selection 后单击页面中的其他位置(导致 select 控件失去焦点)。 on:click 有点效果,但很烦人。

on:change 似乎正确 - 如何清除此警告?

您需要做的就是在 select 元素所在的行上方添加注释。

<!-- svelte-ignore a11y-no-onchange -->

您需要重新加载 window 以清除错误。 https://svelte.dev/docs#Comments 如果你好奇如何在 VS 代码中禁用警告,它会在警告后告诉你它的名称,括号中的任何内容都在 svelte-ignore.

之后