반응형
자식 컴포넌트 코드
<script>
let count = 0;
export const increment = () => {
count += 1;
}
</script>
<p>{count}</p>
부모 컴포넌트 코드
<script>
import Child from './Child.svelte';
let childComponent;
// let call;
</script>
<Child bind:this={childComponent} />
<button on:click={()=>{ childComponent.increment() }}>
자식 컴포넌트의 함수 호출
</button>
<!--
<Child bind:increment={call} />
<button on:click={()=>{ call() }}>
자식 컴포넌트의 함수 호출2
</button>
-->
반응형
'IT > 스벨트(Svelte)' 카테고리의 다른 글
스벨트에서 Flowbite 설치 방법 (0) | 2024.05.23 |
---|---|
스벨트에서 shadcn/ui 설치 방법 (0) | 2024.05.21 |
스벨트에서 구글 머티리얼 아이콘(SVG) 사용 방법 (0) | 2024.05.19 |
스벨트에서 Tailwind css 설치 방법 (0) | 2024.05.19 |
스벨트 설치 방법 (0) | 2024.05.19 |