本文共 831 字,大约阅读时间需要 2 分钟。
如何安装svelte
In Svelte you can listen for changes in the component state, and update other variables.
在Svelte中,您可以侦听组件状态的变化,并更新其他变量。
For example if you have a count
variable:
例如,如果您有一个count
变量:
and you update it by clicking a button:
然后您通过单击按钮进行更新:
{count}
You can listen for changes on count
using the special syntax $:
which defines a new block that Svelte will re-run when any variable referenced into it changes.
您可以使用特殊语法$:
监听count
变化$:
它定义了一个新块,当其中引用的任何变量发生变化时,Svelte都会重新运行。
Here’s an example:
这是一个例子:
{count}
I used the block:
我用了块:
$: console.log(`${count}`)
You can write more than one of them:
您可以编写其中一个以上的代码:
And you can also add a block to group more than one statement:
您还可以添加一个块来组合多个语句:
I used a console.log() call in there, but you can update other variables too:
我在那里使用了console.log()调用,但是您也可以更新其他变量:
翻译自:
如何安装svelte
转载地址:http://kvqgb.baihongyu.com/