본문 바로가기
Framework/Svelte

[Svelte] $ 반응성 구문

by pcm9881 2022. 7. 21.

Svelte $ 반응성 구문

<script>
let num = 0;

$: plus = num + 1;

$: {
    console.log(num);
    console.log(plus);
}

// num이 변경되면 console.log(num)을 실행
$: num, console.log(num);
</script>

참조

스벨트 문서: https://svelte.dev/docs#component-format-script-3-$-marks-a-statement-as-reactive 

 

Docs • Svelte

Documentation Before we begin This page contains detailed API reference documentation. It's intended to be a resource for people who already have some familiarity with Svelte. If that's not you (yet), you may prefer to visit the interactive tutorial or the

svelte.dev

 

728x90

댓글