Svelte 語句

2023-02-20 16:49 更新

我們不僅提供了聲明反應(yīng)式的 ,我們還可以運(yùn)行反應(yīng)式的 語句。例如,當(dāng) ?count? 的值改變時(shí)就輸出到日志中:

$: console.log(`the count is ${count}`);

你可以輕松地將一組語句組合成一個(gè)代碼塊:

$: {
	console.log(`the count is ${count}`);
	alert(`I SAID THE COUNT IS ${count}`);
}

你甚至可以將 $: 放在= if 代碼塊前面:

$: if (count >= 10) {
	alert(`count is dangerously high!`);
	count = 9;
}


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)