{"id":315625,"date":"2020-12-27T21:00:31","date_gmt":"2020-12-27T21:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=315625"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-12-27T21:00:31","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=315625","title":{"rendered":"\u041a\u0430\u043a\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f Vuex?"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">Vuex \u2014 \u0441\u0442\u0435\u0439\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0434\u043b\u044f Vue \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0415\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u2014 Vuex 4, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u043e\u0442\u043e\u0432\u0430 \u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0435\u043b\u0438\u0437\u0443. \u041e\u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Vue 3, \u043d\u043e \u043d\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Vuex \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043e\u043d\u0438 \u043d\u0430\u0434\u0435\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0440\u0435\u043b\u0438\u0437\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e\u043a\u0430 Vuex 4 \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0441\u044f \u043a \u0432\u044b\u0445\u043e\u0434\u0443, \u043e\u0434\u0438\u043d \u0438\u0437 \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, <a href=\"https:\/\/github.com\/kiaking\" rel=\"nofollow\">Kia King Ishii<\/a> (\u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 core-\u043a\u043e\u043c\u0430\u043d\u0434\u044b) \u0443\u0436\u0435 <a href=\"https:\/\/www.youtube.com\/watch?v=dQ5btkDrdJ8\" rel=\"nofollow\">\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u043d\u0430\u043c\u0438<\/a> \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439, 5 \u0432\u0435\u0440\u0441\u0438\u0438. \u0421\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u0430\u043d\u044b \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043e. \u041e \u043d\u0435\u043c \u0438 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c Vue 3 \u0438 <a href=\"https:\/\/v3.vuejs.org\/guide\/composition-api-introduction.html#why-composition-api\" rel=\"nofollow\">\u0421omposition API<\/a>, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u0442\u0430\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u201c<a href=\"https:\/\/dev.to\/blacksonic\/you-might-not-need-vuex-with-vue-3-52e4\" rel=\"nofollow\">\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d Vuex<\/a>\u201d \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u0433\u0438\u0431\u043a\u0438\u0439 \u0438 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Composition API \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 <code>provide\/inject<\/code>. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043d\u043e \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442, \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438: \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e, \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0432 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438, \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f, \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3p\/sa\/pb\/3psapbo45lipr1l_jhi55sgtxo8.png\"><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0421\u0435\u0439\u0447\u0430\u0441 \u0443 Vue \u0435\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 <a href=\"https:\/\/github.com\/vuejs\/vue-devtools\" rel=\"nofollow\">\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/a>, \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0449\u0435\u0435 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435. \u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u0442\u0435\u0440\u0435\u0439, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041d\u043e \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0441 Vuex 5 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442. \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0443\u0442 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u044e\u0441\u043e\u0432, \u043a\u0430\u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043b\u044e\u0441\u044b \u043d\u0430\u043c \u043e\u0431\u0435\u0449\u0430\u044e\u0442.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u0430<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u0412o Vuex 4, \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">import { createStore } from 'vuex'  export const counterStore = createStore({   state: {     count: 0   },      getters: {     double (state) {       return state.count * 2     }   },      mutations: {     increment (state) {       state.count++     }   },      actions: {     increment (context) {       context.commit('increment')     }   } }) <\/code><\/pre>\n<p>  \u0421\u0442\u043e\u0440 \u0432\u0441\u0435 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 4 \u0447\u0430\u0441\u0442\u0435\u0439: \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 (state), \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435; \u0433\u0435\u0442\u0442\u0435\u0440\u044b (getters), \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f; \u043c\u0443\u0442\u0430\u0446\u0438\u0438 (mutations), \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u044d\u043a\u0448\u0435\u043d\u044b (actions), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0441\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u043d\u0438\u043c. \u041e\u0431\u044b\u0447\u043d\u043e \u044d\u043a\u0448\u0435\u043d\u044b \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043c\u0443\u0442\u0430\u0446\u0438\u044e (\u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435), \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c <b>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438<\/b>) \u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443. \u041a\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c Vuex 5?<\/p>\n<pre><code class=\"javascript\">import { defineStore } from 'vuex'  export const counterStore = defineStore({   name: 'counter',      state() {     return { count: 0 }   },      getters: {     double () {       return this.count * 2     }   },      actions: {     increment () {       this.count++     }   } }) <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c \u2014 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 <code>createStore<\/code> \u0432 <code>defineStore<\/code>. \u0427\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>name<\/code> \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438 \u0441\u0442\u043e\u0440\u0430. \u0414\u043e \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u043b\u0438 \u0441\u0442\u043e\u0440\u044b \u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u0438, \u0430 \u0438\u043c\u0435\u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0431\u044b\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u0430\u043b\u0435\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u043e\u043d\u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>namespaced<\/code>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0442\u043e\u0442 \u0436\u0435 \u0442\u0438\u043f \u043c\u0443\u0442\u0430\u0446\u0438\u0439 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0414\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u044d\u0442\u0438\u043c, \u043d\u043e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <a href=\"https:\/\/vuex.vuejs.org\/guide\/modules.html#namespacing\" rel=\"nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a> \u044f, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044e. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u0440 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c <code>state<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 <code>data<\/code> \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0441\u043d\u0443\u043b\u0438\u0441\u044c \u0438 \u0433\u0435\u0442\u0442\u0435\u0440\u043e\u0432, \u0432\u043c\u0435\u0441\u0442\u043e <code>state<\/code> \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>this<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c. \u0422\u043e\u0442 \u0436\u0435 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u0438 \u043a \u044d\u043a\u0448\u0435\u043d\u0430\u043c, <code>this<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>stat\u0435<\/code> \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0441 \u044d\u043a\u0448\u0435\u043d\u0430\u043c\u0438. Kia <a href=\"https:\/\/www.youtube.com\/watch?t=505&amp;v=dQ5btkDrdJ8\" rel=\"nofollow\">\u043e\u0442\u043c\u0435\u0447\u0430\u043b<\/a>, \u0447\u0442\u043e \u043c\u0443\u0442\u0430\u0446\u0438\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u0430\u043c\u0438, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0432\u043d\u044b\u043c\u0438, \u0432\u0438\u0434\u0438\u043c\u043e \u044d\u0442\u043e \u0438 \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f. \u041e\u043d \u043d\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c \u0441\u0442\u043e\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0422\u0443\u0442, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Flux \u043f\u0430\u0442\u0442\u0435\u0440\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u043f\u043e\u043e\u0449\u0440\u044f\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437 \u044d\u043a\u0448\u0435\u043d\u043e\u0432.<\/p>\n<p>  <b>\u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435:<\/b> \u0442\u0435, \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Composition API \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0434\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0447\u0442\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u0430 \u0432 \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u043c\u0430\u043d\u0435\u0440\u0435.<\/p>\n<pre><code class=\"javascript\">import { ref, computed } from 'vue' import { defineStore } from 'vuex'  export const counterStore = defineStore('counter', () =&gt; {   const count = ref(0)    const double = computed(() =&gt; count.value * 2)      function increment () {     count.value++   }    return { count, double, increment }   }) <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0438\u043c\u044f \u0441\u0442\u043e\u0440\u0430, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>defineStore<\/code>. \u041e\u0441\u0442\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0436\u0435 \u0447\u0430\u0441\u0442\u044c, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 Composition API, \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043a\u0430\u043a \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u043c API.<\/p>\n<h3>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u043e\u0440\u0430<\/h3>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0441 \u0436\u0434\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0438\u0441\u0430\u0442\u044c, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u043e\u0440\u0430 \u0432 5-\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 4-\u043e\u0439. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 <code>createStore<\/code>, \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0435\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 <code>app.use<\/code> \u0438\u043b\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<pre><code class=\"javascript\">import { createApp } from 'vue' import App from '.\/App.vue' import store from '.\/store'  const app = createApp(App)  app.use(store) app.mount('#app')  \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a `this.$store` \/\/ \u0418\u043b\u0438 \u043a `useStore()` \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 Composition API  import store from '.\/store'  store.state.count \/\/ -&gt; 0 store.commit('increment') store.dispatch('increment') store.getters.double \/\/ -&gt; 4 <\/code><\/pre>\n<p>  \u0412 5-\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u043c\u044b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 Vuex, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u044e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0430\u0447\u0435:<\/p>\n<pre><code class=\"javascript\">import { createApp } from 'vue' import { createVuex } from 'vuex' import App from '.\/App.vue'  const app = createApp(App) const vuex = createVuex()  app.use(vuex) app.mount('#app') <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 Vuex, \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443. \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">import { defineComponent } from 'vue' import store from '.\/store'  export default defineComponent({   name: 'App',    computed: {     counter () {       return this.$vuex.store(store)     }   } }) <\/code><\/pre>\n<p>  \u0412\u044b\u0437\u043e\u0432 <code>$vuex.store<\/code> \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u043e\u0440 (\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043f\u0440\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 <code>createStore<\/code>). \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043e\u0431\u0449\u0430\u044f\u0441\u044c \u043a \u044d\u0442\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0443 \u0447\u0435\u0440\u0435\u0437 <code>$vuex.store<\/code>, \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e <code>this.counter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u043a\u043e\u0434\u0435. \u0422\u0430\u043a \u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 <code>createVuex()<\/code>.<\/p>\n<p>  \u0418 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f Composition API, \u0433\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e <code>$vuex.store<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>useStore<\/code>.<\/p>\n<pre><code class=\"javascript\">import { defineComponent } from 'vue' import { useStore } from 'vuex' import store from '.\/store'  export default defineComponent({   setup () {     const counter = useStore(store)      return { counter }   } }) <\/code><\/pre>\n<p>  \u0423 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 (\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u043e\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b) \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043a\u0430\u043a \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430, \u0442\u0430\u043a \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043c, \u0433\u0434\u0435 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (\u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0448\u044c \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c). \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c DI, \u0442\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>provide<\/code>:<\/p>\n<pre><code class=\"javascript\">import { createApp } from 'vue' import { createVuex } from 'vuex' import App from '.\/App.vue' import store from '.\/store'  const app = createApp(App) const vuex = createVuex()  app.use(vuex) app.provide('name', store) app.mount('#app') <\/code><\/pre>\n<p>  \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u043e\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u043e\u0440\u0430 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 (\u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <code>name<\/code> \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438 \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0435):<\/p>\n<pre><code class=\"javascript\">import { defineComponent } from 'vue'  export default defineComponent({   name: 'App',   inject: ['name'] })  \/\/ Composition API  import { defineComponent, inject } from 'vue'  export default defineComponent({   setup () {     const store = inject('name')      return { store }   } }) <\/code><\/pre>\n<p>  \u0412\u043e\u0441\u0442\u043e\u0440\u0433\u0430 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u043e\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u044f\u0432\u043d\u043e \u0438 \u0433\u0438\u0431\u043a\u043e, \u0447\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0422\u0430\u043a \u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u0421\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">store.state.count            \/\/ State store.getters.double         \/\/ Getters store.commit('increment')    \/\/ Mutations store.dispatch('increment')  \/\/ Actions <\/code><\/pre>\n<p>  \u0412 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"javascript\">store.count        \/\/ State store.double       \/\/ Getters store.increment()  \/\/ Actions <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u044d\u043a\u0448\u0435\u043d\u044b) \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0434\u0435\u043b\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043d\u0438\u043c\u0438 \u043f\u0440\u043e\u0449\u0435 \u0438 \u043b\u043e\u0433\u0438\u0447\u043d\u0435\u0435. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>mapState<\/code>, <code>mapGetters<\/code>, <code>mapActions<\/code> \u0438 <code>mapMutations<\/code>, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f <a href=\"https:\/\/next.vuex.vuejs.org\/guide\/composition-api.html#accessing-state-and-getters\" rel=\"nofollow\">\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0445<\/a> \u0441\u0432\u043e\u0439\u0441\u0442\u0432.<\/p>\n<h3>\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u2014 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435. \u041c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0432\u043e Vuex 5 \u0443 \u043d\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c. \u042d\u0442\u043e \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u0440\u044f\u043c\u043e \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u041f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u0440\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u0435? \u0412 4-\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d \u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>rootGetters<\/code> \u0438 <code>rootState<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u0441\u0442\u043e\u0440\u0430\u043c \u0432 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 (\u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 3-\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438). \u041f\u043e\u0434\u0445\u043e\u0434 \u0432 Vuex 5 \u0438\u043d\u043e\u0439:<\/p>\n<pre><code class=\"javascript\">\/\/ store\/greeter.js import { defineStore } from 'vuex'  export default defineStore({   name: 'greeter',   state () {     return { greeting: 'Hello' }   } })  \/\/ store\/counter.js import { defineStore } from 'vuex' import greeterStore from '.\/greeter'  export default defineStore({   name: 'counter',    use () {     return { greeter: greeterStore }   },      state () {     return { count: 0 }   },      getters: {     greetingCount () {       return `${this.greeter.greeting} ${this.count}'     }   } })<\/code><\/pre>\n<p>  \u041c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u043e\u0440, \u0437\u0430\u0442\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 <code>use<\/code> \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f. \u0412\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0435\u0449\u0435 \u043f\u0440\u043e\u0449\u0435 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0421omposition API:<\/p>\n<pre><code class=\"javascript\">\/\/ store\/counter.js import { ref, computed } from 'vue' import { defineStore } from 'vuex' import greeterStore from '.\/greeter'  export default defineStore('counter', ({use}) =&gt; {   const greeter = use(greeterStore)   const count = 0    const greetingCount = computed(() =&gt; {     return  `${greeter.greeting} ${this.count}`   })    return { count, greetingCount } }) <\/code><\/pre>\n<p>  \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u043e \u0447\u0435\u043c \u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c, \u044d\u0442\u043e <code>use<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a <code>vuex.store<\/code> \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0442\u043e\u0440\u043e\u0432.<\/p>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 TypeScript<\/h3>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0432 API \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0439, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 TypeScript \u0432 4 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u043d\u0430\u043c \u0432\u0441\u0435 \u0435\u0449\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u0412\u044b\u0445\u043e\u0434 \u0436\u0435 5 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u0430\u0441\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0438\u043f\u044b, \u0442\u0430\u043c \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0438 \u0442\u0430\u043c \u0433\u0434\u0435 \u043c\u044b \u044d\u0442\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  Vuex 5 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0435\u0449\u0430\u044e\u0449\u0435 \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u0438\u0435 \u0438 \u043e\u0436\u0438\u0434\u0430\u044e\u0442 (\u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u044b\u0445 \u043d\u0435\u0434\u043e\u0447\u0435\u0442\u043e\u0432, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438). \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439 \u0438 \u043c\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/vuejs\/rfcs\/pulls\" rel=\"nofollow\">Vue RFCs<\/a> \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/535232\/\"> https:\/\/habr.com\/ru\/post\/535232\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">Vuex \u2014 \u0441\u0442\u0435\u0439\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0434\u043b\u044f Vue \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0415\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u2014 Vuex 4, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u043e\u0442\u043e\u0432\u0430 \u043a \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0435\u043b\u0438\u0437\u0443. \u041e\u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 Vue 3, \u043d\u043e \u043d\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e Vuex \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u0435\u0433\u043e \u043a\u0430\u043a \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043e\u043d\u0438 \u043d\u0430\u0434\u0435\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0440\u0435\u043b\u0438\u0437\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e\u043a\u0430 Vuex 4 \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0441\u044f \u043a \u0432\u044b\u0445\u043e\u0434\u0443, \u043e\u0434\u0438\u043d \u0438\u0437 \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, <a href=\"https:\/\/github.com\/kiaking\" rel=\"nofollow\">Kia King Ishii<\/a> (\u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 core-\u043a\u043e\u043c\u0430\u043d\u0434\u044b) \u0443\u0436\u0435 <a href=\"https:\/\/www.youtube.com\/watch?v=dQ5btkDrdJ8\" rel=\"nofollow\">\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u043d\u0430\u043c\u0438<\/a> \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439, 5 \u0432\u0435\u0440\u0441\u0438\u0438. \u0421\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u0430\u043d\u044b \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043e. \u041e \u043d\u0435\u043c \u0438 \u043f\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u0447\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-315625","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=315625"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315625\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}