📘
만들면서 배우는 svelte
  • 1. svelte 소개
  • 2. 개발환경 설정
    • 수업 코드 및 문서 가이드 안내
    • 비주얼스튜디오 & REPL
    • 설치
  • 3. 컴포넌트 - 기본
    • 앱 구조 설명 : main.js, App.js, 폴더구조
    • 컴포넌트 기본 : 레이아웃 샘플 구성(여러 component 연동)
    • state
    • reactivity
    • 컴포넌트 통신방법용 기본 앱 코드
    • 컴포넌트 통신방법 1 : props
    • 컴포넌트 통신방법 2 : dispatch
    • 컴포넌트 통신방법 3 : context API
    • 컴포넌트 통신방법 4 : store
  • 4. 컴포넌트 - 템플릿 제어
    • {#if ...}
    • {#each ...}
    • bind
    • event
    • slot
    • lifecycle (생명주기)
  • 5. 스타일 및 효과
    • 동적 css 적용방법
    • transition : 화면전환
    • todo store 적용 3 : 컴포넌트에 store 연동
  • 6. 실습 1 - TODO 만들기
  • 7. 실습 2 - store를 통한 todo 리팩토링
  • 8. 라우터 - routify
    • 소개 & 설치
    • 라우팅 생성
    • 링크 생성
    • parameter 전달 및 받기
    • todo 서비스에 적용
  • 9. ajax 처리
    • fetch와 {#await ..} 적용
    • axios 적용
  • 10 . 기타
    • 경로 쉽게 적용하기
    • javascript 배열 조작 메서드
    • 화살표 함수
Powered by GitBook
On this page

Was this helpful?

  1. 3. 컴포넌트 - 기본

컴포넌트 통신방법 4 : store

예제 - store

  • store.js

import  { writable } from 'svelte/store'

let value = 0

export const count = writable(value)
  • App.svelte

<script>
import { setContext } from 'svelte'

import PanelComponent from './components/panelComponent.svelte'

</script>

<PanelComponent />
  • panelComponent.svelte

<script>
import ButtonComponent from './buttonComponent.svelte'

import { count } from '../store'
</script>

<div class="penal">
  <h1>{$count}</h1>
  
  <ButtonComponent  />
  
</div>

<style>
  .penal {
    padding: 20px;
    display:flex;
    flex-direction: column;
    justify-items: center;
    justify-content: space-around;
    align-items: center;
    height: 500px;
    width:400px;
    background: #e2e2e2;
    border: 1px solid #777777;
  }
</style>
  • buttonComponent.svelte

<script>
import { count } from '../store'

function handleIncrementCount() {
  count.update(count => count + 1)
}

</script>

<button on:click={handleIncrementCount} >
  increment count [{$count}]
</button>

Previous컴포넌트 통신방법 3 : context APINext{#if ...}

Last updated 4 years ago

Was this helpful?

[만들면서 배우는 Svelte]
만들면서 배우는 svelte