vuex-help
Version:
a utilies library reduce boilerplate for vuex
524 lines (232 loc) • 20.5 kB
HTML
<html lang="kr" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>시작하기 · Vuex</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../gitbook/style.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-vuejs/vue.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="prev" href="intro.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=vuejs" id="_carbonads_js"></script>
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="./">
<a href="./">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" >
<a target="_blank" href="https://github.com/vuejs/vuex/tree/1.0/docs">
1.0 버전 문서를 보려면?
</a>
</li>
<li class="chapter " data-level="1.3" >
<a target="_blank" href="https://github.com/vuejs/vuex/releases">
릴리즈 노트
</a>
</li>
<li class="chapter " data-level="1.4" data-path="installation.html">
<a href="installation.html">
설치
</a>
</li>
<li class="chapter " data-level="1.5" data-path="intro.html">
<a href="intro.html">
Vuex가 무엇인가요?
</a>
</li>
<li class="chapter active" data-level="1.6" data-path="getting-started.html">
<a href="getting-started.html">
시작하기
</a>
</li>
<li class="chapter " data-level="1.7" >
<span>
핵심 컨셉
</span>
<ul class="articles">
<li class="chapter " data-level="1.7.1" data-path="state.html">
<a href="state.html">
상태
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="getters.html">
<a href="getters.html">
Getters
</a>
</li>
<li class="chapter " data-level="1.7.3" data-path="mutations.html">
<a href="mutations.html">
변이
</a>
</li>
<li class="chapter " data-level="1.7.4" data-path="actions.html">
<a href="actions.html">
액션
</a>
</li>
<li class="chapter " data-level="1.7.5" data-path="modules.html">
<a href="modules.html">
모듈
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.8" data-path="structure.html">
<a href="structure.html">
애플리케이션 구조
</a>
</li>
<li class="chapter " data-level="1.9" data-path="plugins.html">
<a href="plugins.html">
플러그인
</a>
</li>
<li class="chapter " data-level="1.10" data-path="strict.html">
<a href="strict.html">
Strict 모드
</a>
</li>
<li class="chapter " data-level="1.11" data-path="forms.html">
<a href="forms.html">
폼 핸들링
</a>
</li>
<li class="chapter " data-level="1.12" data-path="testing.html">
<a href="testing.html">
테스팅
</a>
</li>
<li class="chapter " data-level="1.13" data-path="hot-reload.html">
<a href="hot-reload.html">
핫 리로딩
</a>
</li>
<li class="chapter " data-level="1.14" data-path="api.html">
<a href="api.html">
API 레퍼런스
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >시작하기</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="시작하기">시작하기</h1>
<p>모든 Vuex 애플리케이션의 중심에는 <strong>store</strong> 가 있습니다. "저장소"는 기본적으로 애플리케이션 <strong>상태</strong> 를 보유하고있는 컨테이너입니다. Vuex 저장소가 일반 전역 개체와 두 가지 다른 점이 있습니다.</p>
<ol>
<li>Vuex store는 반응형 입니다. Vue 컴포넌트는 상태를 검색할 때 저장소의 상태가 변경되면 효율적으로 대응하고 업데이트합니다.</li>
<li>저장소의 상태를 직접 변경할 수 없습니다. 저장소의 상태를 변경하는 유일한 방법은 명시적인 <strong>커밋을 이용한 변이</strong> 입니다. 이렇게하면 모든 상태에 대한 추적이 가능한 기록이 남을 수 있으며 툴을 사용하여 앱을 더 잘 이해할 수 있습니다.</li>
</ol>
<h3 id="가장-단순한-저장소">가장 단순한 저장소</h3>
<blockquote>
<p><strong>참고:</strong> 모든 예제는 ES2015 문법을 사용합니다. 사용하고 있지 않은 경우 <a href="https://babeljs.io/docs/learn-es2015/" target="_blank">꼭 사용해야 합니다!</a></p>
</blockquote>
<p>Vuex를 <a href="installation.html">설치</a>한 후 저장소를 만들어 봅시다. 매우 간단합니다. 초기 상태 객체와 일부 변이를 제공하십시오.</p>
<pre class="language-"><code class="lang-js"><span class="token comment" spellcheck="true">// 모듈 시스템을 사용하는 경우 Vue.use(Vuex)를 먼저 호출해야합니다.</span>
<span class="token keyword">const</span> store <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Vuex<span class="token punctuation">.</span>Store</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
state<span class="token punctuation">:</span> <span class="token punctuation">{</span>
count<span class="token punctuation">:</span> <span class="token number">0</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
mutations<span class="token punctuation">:</span> <span class="token punctuation">{</span>
increment <span class="token punctuation">(</span>state<span class="token punctuation">)</span> <span class="token punctuation">{</span>
state<span class="token punctuation">.</span>count<span class="token operator">++</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre>
<p>이제 state 객체에 <code>store.state</code>로 접근하여 <code>store.commit</code> 메소드로 상태 변경을 트리거 할 수 있습니다.</p>
<pre class="language-"><code class="lang-js">store<span class="token punctuation">.</span><span class="token function">commit</span><span class="token punctuation">(</span><span class="token string">'increment'</span><span class="token punctuation">)</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>store<span class="token punctuation">.</span>state<span class="token punctuation">.</span>count<span class="token punctuation">)</span> <span class="token comment" spellcheck="true">// -> 1</span>
</code></pre>
<p>다시 말해, <code>store.state.count</code>를 직접 변경하는 대신 변이를 수행하는 이유는 명시적으로 추적을 하기 때문입니다. 이 간단한 규칙에 따라 의도를보다 명확하게 표현할 수 있으므로 코드를 읽을 때 상태 변화를 더 잘 지켜볼 수 있습니다. 또한 모든 변이를 기록하고 상태 스냅샷을 저장하거나 시간 흐름에 따라 디버깅을 할 수 있는 도구를 제공합니다.</p>
<p>컴포넌트 안에서 저장소 상태를 사용하는 것은 단순히 계산된 속성 내에서 상태를 반환하는 것입니다. 변경을 트리거하는 것은 컴포넌트 메소드에서 변경을 커밋하는 것을 의미합니다.</p>
<p>다음은 <a href="https://jsfiddle.net/n9jmu5v7/1269/" target="_blank">가장 기본적인 Vuex 카운터 앱</a>의 예입니다.</p>
<p>이제, 우리는 각 핵심 개념에 대해 더 자세히 설명 할 것입니다. <a href="state.html">State</a>부터 시작해 보겠습니다.</p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
<script src="//m.servedby-buysellads.com/monetization.js" type="text/javascript"></script>
<div class="bsa-cpc"></div>
<script>
(function(){
if(typeof _bsa !== 'undefined' && _bsa) {
_bsa.init('default', 'CKYD62QM', 'placement:vuejsorg', {
target: '.bsa-cpc',
align: 'horizontal',
disable_css: 'true'
});
}
})();
</script>
</div>
<a href="intro.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Vuex가 무엇인가요?">
<i class="fa fa-angle-left"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"시작하기","level":"1.6","depth":1,"next":{"title":"핵심 컨셉","level":"1.7","depth":1,"ref":"","articles":[{"title":"상태","level":"1.7.1","depth":2,"path":"state.md","ref":"state.md","articles":[]},{"title":"Getters","level":"1.7.2","depth":2,"path":"getters.md","ref":"getters.md","articles":[]},{"title":"변이","level":"1.7.3","depth":2,"path":"mutations.md","ref":"mutations.md","articles":[]},{"title":"액션","level":"1.7.4","depth":2,"path":"actions.md","ref":"actions.md","articles":[]},{"title":"모듈","level":"1.7.5","depth":2,"path":"modules.md","ref":"modules.md","articles":[]}]},"previous":{"title":"Vuex가 무엇인가요?","level":"1.5","depth":1,"path":"intro.md","ref":"intro.md","articles":[]},"dir":"ltr"},"config":{"plugins":["edit-link","prism","-highlight","github","-highlight","github"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/vuejs/vuex/"},"livereload":{},"search":{},"theme-vuejs":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"Edit This Page","base":"https://github.com/vuejs/vuex/tree/dev/docs"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Vuex","language":"kr","links":{"sharing":{"facebook":false,"twitter":false}},"gitbook":"2.x.x"},"file":{"path":"getting-started.md","mtime":"2018-02-17T07:20:49.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-03-02T20:43:43.208Z"},"basePath":".","book":{"language":"kr"}});
});
</script>
</div>
<script src="../gitbook/gitbook.js"></script>
<script src="../gitbook/theme.js"></script>
<script src="../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
<script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
<script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
</body>
</html>