我试图将变量从我的商店绑定到组件,但收到错误:
[!] (plugin svelte) ValidationError: Cannot bind to a variable which is not writable
Run Code Online (Sandbox Code Playgroud)
这是我的示例代码:
<Textfield bind:value={startDate} label="Start Date" type="datetime-local" />
Run Code Online (Sandbox Code Playgroud)
要使用存储变量,可以依赖“更新”回调,或使用特定语法
<Textfield bind:value={$startDate} label="Start Date" type="datetime-local" />
Run Code Online (Sandbox Code Playgroud)
有关 Svelte 教程的更多信息:https://svelte.dev/tutorial/store-bindings
| 归档时间: |
|
| 查看次数: |
4378 次 |
| 最近记录: |