如何在 Svelte 中有条件地禁用字段?

Cla*_*nda 9 html svelte

在 Angular 2+(例如)中,我可以使用以下语法有条件地禁用字段:

<input [disabled]="booleanCondition" type="text">
Run Code Online (Sandbox Code Playgroud)

在 Svelte 中,我尝试执行以下操作,但不起作用:

<input {booleanCondition ? 'disabled=""' : ''} type="text">
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

Ric*_*ris 19

像这样

<input disabled={booleanCondition}>
Run Code Online (Sandbox Code Playgroud)