{"id":452762,"date":"2025-03-22T15:00:35","date_gmt":"2025-03-22T15:00:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=452762"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=452762","title":{"rendered":"<span>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0436\u0438\u0437\u043d\u044c \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438 \u0438\u0445 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432: \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u0444\u0430\u043d\u0430\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 DRY<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0411\u0438\u0437\u043d\u0435\u0441 \u0432\u044b\u0434\u0432\u0438\u0433\u0430\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440: \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0443\u043c\u043c\u044b \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b<\/h4>\n<h3>\u041f\u0435\u0440\u0432\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435: \u0441\u0443\u043c\u043c\u0430 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u0445<\/h3>\n<pre><code class=\"javascript\">const SumComponent = (a, b) =&gt; `\"${a + b}\"`;<\/code><\/pre>\n<h3>\u0412\u0442\u043e\u0440\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u043a\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435<\/h3>\n<pre><code class=\"javascript\">const SumComponent = (a, b, tag) =&gt; `\"${a + b}\"-${tag}`;<\/code><\/pre>\n<h3>\u0422\u0440\u0435\u0442\u044c\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<pre><code class=\"javascript\">const SumComponent = (a, b, tag, isMultiple) =&gt;    `${isMultiple ? a * b : ''}-\"${a + b}\"-${tag}`;<\/code><\/pre>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h4>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 &#171;\u043c\u043e\u043d\u0441\u0442\u0440\u0430&#187; \u0441 \u043a\u0443\u0447\u0435\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u043f\u0441\u044b \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0441\u0442\u0430\u0440\u044b\u0445, \u0447\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u043c.<\/p>\n<h3>\u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438: \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 (\u043d\u043e \u0441 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c)<\/h3>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u2014 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430. \u042d\u0442\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 DRY, \u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0443\u043c\u043c\u0430 const SumComponent = (a, b) =&gt; `\"${a + b}\"`;  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u0442\u0435\u0433\u043e\u043c const SumComponentAndTag = (a, b, tag) =&gt; `\"${a + b}\"-${tag}`;  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u0442\u0435\u0433\u043e\u043c \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c const SumComponentAndTagAndMultiple = (a, b, tag, isMultiple) =&gt;    `${isMultiple ? a * b : ''}-\"${a + b}\"-${tag}`;<\/code><\/pre>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430<\/h4>\n<p>\u0414\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0443\u043c\u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445.<\/p>\n<h3>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u043b\u0443\u0447\u0448\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f)<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u043d\u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/p>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<pre><code class=\"javascript\">\/\/ \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0443\u043c\u043c\u044b const sum = (a, b) =&gt; a + b;  \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0432\u044b\u0447\u0435\u043a const withQuotes = (fn) =&gt; (a, b) =&gt; `\"${fn(a, b)}\"`;  \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u0430 const withTag = (fn) =&gt; (a, b, tag) =&gt; `${fn(a, b)}-${tag}`;  \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f const withMultiplication = (fn) =&gt; (a, b, isMultiple) =&gt;    isMultiple ? `${a * b}-${fn(a, b)}` : fn(a, b);<\/code><\/pre>\n<h4>\u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h4>\n<pre><code class=\"javascript\">\/\/ \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0443\u043c\u043c\u0430 \u0441 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438 const SumComponent = withQuotes(sum);  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438 \u0438 \u0442\u0435\u0433\u043e\u043c const SumComponentAndTag = (a, b, tag) =&gt; withTag(withQuotes(sum))(a, b, tag);  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438, \u0442\u0435\u0433\u043e\u043c \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c const SumComponentAndTagAndMultiple = (a, b, tag, isMultiple) =&gt;    withMultiplication(withTag(withQuotes(sum)))(a, b, isMultiple) + `-${tag}`;<\/code><\/pre>\n<h4>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/h4>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>: \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435<\/strong>: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043a\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f\u043c.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043d\u0430 Vue.js<\/h3>\n<h4>Composition API<\/h4>\n<h4>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u044b (composables)<\/h4>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<h3>useSum.js\u00a0\u2014 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0443\u043c\u043c\u044b<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useSum(a, b) {   const sum = computed(() =&gt; a + b);   return { sum }; }<\/code><\/pre>\n<h3>useQuotes.js\u00a0\u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0432\u044b\u0447\u0435\u043a<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useQuotes(value) {   const quotedValue = computed(() =&gt; `\"${value.value}\"`);   return { quotedValue }; }<\/code><\/pre>\n<h3>useTag.js\u00a0\u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u0430<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useTag(value, tag) {   const taggedValue = computed(() =&gt; `${value.value}-${tag}`);   return { taggedValue }; }<\/code><\/pre>\n<h3>useMultiplication.js\u00a0\u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useMultiplication(a, b, value, isMultiple) {   const multipliedValue = computed(() =&gt;      isMultiple.value ? `${a.value * b.value}-${value.value}` : value.value   );   return { multipliedValue }; }<\/code><\/pre>\n<h4>2. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u043e\u0432<\/h4>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u00a0SumComponent<\/h3>\n<pre><code class=\"javascript\">&lt;script setup&gt; import { useSum, useQuotes } from '.\/composables';  const props = defineProps({   a: Number,   b: Number, });  const { sum } = useSum(props.a, props.b); const { quotedValue } = useQuotes(sum); &lt;\/script&gt;  &lt;template&gt;   &lt;span&gt;{{ quotedValue }}&lt;\/span&gt; &lt;\/template&gt;<\/code><\/pre>\n<h3>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u00a0SumComponentAndTag<\/h3>\n<pre><code class=\"javascript\">&lt;script setup&gt; import { useSum, useQuotes, useTag } from '.\/composables';  const props = defineProps({   a: Number,   b: Number,   tag: String, });  const { sum } = useSum(props.a, props.b); const { quotedValue } = useQuotes(sum); const { taggedValue } = useTag(quotedValue, props.tag); &lt;\/script&gt;  &lt;template&gt;   &lt;span&gt;{{ taggedValue }}&lt;\/span&gt; &lt;\/template&gt;<\/code><\/pre>\n<h4>3. \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430<\/h4>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>: \u041a\u0430\u0436\u0434\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>: \u041a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c<\/strong>: \u0412\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u043f\u0441\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435<\/strong>: \u041b\u0435\u0433\u043a\u043e \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u0435\u043b\u043a\u0438\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/strong>: \u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<\/li>\n<\/ol>\n<h4>4. \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432<\/h4>\n<pre><code class=\"javascript\">&lt;template&gt;   &lt;div&gt;     &lt;!-- \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0443\u043c\u043c\u0430 --&gt;     &lt;SumComponent :a=\"2\" :b=\"3\" \/&gt;      &lt;!-- \u0421\u0443\u043c\u043c\u0430 \u0441 \u0442\u0435\u0433\u043e\u043c --&gt;     &lt;SumComponentAndTag :a=\"2\" :b=\"3\" tag=\"result\" \/&gt;    &lt;\/div&gt; &lt;\/template&gt;  &lt;script setup&gt; import SumComponent from '.\/components\/SumComponent.vue'; import SumComponentAndTag from '.\/components\/SumComponentAndTag.vue'; &lt;\/script&gt;<\/code><\/pre>\n<h4>5. \u0418\u0442\u043e\u0433<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0useComposable\u00a0\u0432\u043e Vue 3 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u0438\u0431\u043a\u0438\u0435 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043f\u0440\u043e\u0449\u0430\u0442\u044c \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>Options API<\/h4>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h3>\n<ol>\n<li>\n<p><strong>\u0421\u043b\u043e\u0442\u044b<\/strong>: \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0442\u044c \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0438\u043a\u0441\u0438\u043d\u044b<\/strong>: \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u0438 \u043d\u0435\u044f\u0432\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u044b\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438<\/strong>: \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<\/strong>\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c DRY \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/strong>\u00a0\u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0433\u0438\u0431\u043a\u0438\u043c \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>Composition API<\/strong>\u00a0\u0432\u043e Vue \u2014 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432<\/strong>: \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u043c\u0435\u043b\u043a\u0438\u0435, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441 \u043c\u0435\u0436\u0434\u0443 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0434\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/893370\/\"> https:\/\/habr.com\/ru\/articles\/893370\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432: \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u0444\u0430\u043d\u0430\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 DRY<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0411\u0438\u0437\u043d\u0435\u0441 \u0432\u044b\u0434\u0432\u0438\u0433\u0430\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440: \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0443\u043c\u043c\u044b \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b<\/h4>\n<h3>\u041f\u0435\u0440\u0432\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435: \u0441\u0443\u043c\u043c\u0430 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u0445<\/h3>\n<pre><code class=\"javascript\">const SumComponent = (a, b) =&gt; `\"${a + b}\"`;<\/code><\/pre>\n<h3>\u0412\u0442\u043e\u0440\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u043a\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435<\/h3>\n<pre><code class=\"javascript\">const SumComponent = (a, b, tag) =&gt; `\"${a + b}\"-${tag}`;<\/code><\/pre>\n<h3>\u0422\u0440\u0435\u0442\u044c\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435<\/h3>\n<pre><code class=\"javascript\">const SumComponent = (a, b, tag, isMultiple) =&gt;    `${isMultiple ? a * b : ''}-\"${a + b}\"-${tag}`;<\/code><\/pre>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h4>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 &#171;\u043c\u043e\u043d\u0441\u0442\u0440\u0430&#187; \u0441 \u043a\u0443\u0447\u0435\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u043f\u0441\u044b \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0441\u0442\u0430\u0440\u044b\u0445, \u0447\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u043c.<\/p>\n<h3>\u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438: \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 (\u043d\u043e \u0441 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c)<\/h3>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u2014 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0435\u0439\u0441\u0430. \u042d\u0442\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 DRY, \u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0443\u043c\u043c\u0430 const SumComponent = (a, b) =&gt; `\"${a + b}\"`;  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u0442\u0435\u0433\u043e\u043c const SumComponentAndTag = (a, b, tag) =&gt; `\"${a + b}\"-${tag}`;  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u0442\u0435\u0433\u043e\u043c \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c const SumComponentAndTagAndMultiple = (a, b, tag, isMultiple) =&gt;    `${isMultiple ? a * b : ''}-\"${a + b}\"-${tag}`;<\/code><\/pre>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430<\/h4>\n<p>\u0414\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0443\u043c\u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445.<\/p>\n<h3>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u043b\u0443\u0447\u0448\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f)<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u043d\u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/p>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<pre><code class=\"javascript\">\/\/ \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0443\u043c\u043c\u044b const sum = (a, b) =&gt; a + b;  \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0432\u044b\u0447\u0435\u043a const withQuotes = (fn) =&gt; (a, b) =&gt; `\"${fn(a, b)}\"`;  \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u0430 const withTag = (fn) =&gt; (a, b, tag) =&gt; `${fn(a, b)}-${tag}`;  \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f const withMultiplication = (fn) =&gt; (a, b, isMultiple) =&gt;    isMultiple ? `${a * b}-${fn(a, b)}` : fn(a, b);<\/code><\/pre>\n<h4>\u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h4>\n<pre><code class=\"javascript\">\/\/ \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0443\u043c\u043c\u0430 \u0441 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438 const SumComponent = withQuotes(sum);  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438 \u0438 \u0442\u0435\u0433\u043e\u043c const SumComponentAndTag = (a, b, tag) =&gt; withTag(withQuotes(sum))(a, b, tag);  \/\/ \u0421\u0443\u043c\u043c\u0430 \u0441 \u043a\u0430\u0432\u044b\u0447\u043a\u0430\u043c\u0438, \u0442\u0435\u0433\u043e\u043c \u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c const SumComponentAndTagAndMultiple = (a, b, tag, isMultiple) =&gt;    withMultiplication(withTag(withQuotes(sum)))(a, b, isMultiple) + `-${tag}`;<\/code><\/pre>\n<h4>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/h4>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>: \u043a\u0430\u0436\u0434\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435<\/strong>: \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043a\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f\u043c.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043d\u0430 Vue.js<\/h3>\n<h4>Composition API<\/h4>\n<h4>1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u044b (composables)<\/h4>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<h3>useSum.js\u00a0\u2014 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u0443\u043c\u043c\u044b<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useSum(a, b) {   const sum = computed(() =&gt; a + b);   return { sum }; }<\/code><\/pre>\n<h3>useQuotes.js\u00a0\u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0432\u044b\u0447\u0435\u043a<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useQuotes(value) {   const quotedValue = computed(() =&gt; `\"${value.value}\"`);   return { quotedValue }; }<\/code><\/pre>\n<h3>useTag.js\u00a0\u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u0430<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useTag(value, tag) {   const taggedValue = computed(() =&gt; `${value.value}-${tag}`);   return { taggedValue }; }<\/code><\/pre>\n<h3>useMultiplication.js\u00a0\u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f<\/h3>\n<pre><code class=\"javascript\">import { computed } from 'vue';  export function useMultiplication(a, b, value, isMultiple) {   const multipliedValue = computed(() =&gt;      isMultiple.value ? `${a.value * b.value}-${value.value}` : value.value   );   return { multipliedValue }; }<\/code><\/pre>\n<h4>2. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u043e\u0432<\/h4>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u00a0SumComponent<\/h3>\n<pre><code class=\"javascript\">&lt;script setup&gt; import { useSum, useQuotes } from '.\/composables';  const props = defineProps({   a: Number,   b: Number, });  const { sum } = useSum(props.a, props.b); const { quotedValue } = useQuotes(sum); &lt;\/script&gt;  &lt;template&gt;   &lt;span&gt;{{ quotedValue }}&lt;\/span&gt; &lt;\/template&gt;<\/code><\/pre>\n<h3>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u00a0SumComponentAndTag<\/h3>\n<pre><code class=\"javascript\">&lt;script setup&gt; import { useSum, useQuotes, useTag } from '.\/composables';  const props = defineProps({   a: Number,   b: Number,   tag: String, });  const { sum } = useSum(props.a, props.b); const { quotedValue } = useQuotes(sum); const { taggedValue } = useTag(quotedValue, props.tag); &lt;\/script&gt;  &lt;template&gt;   &lt;span&gt;{{ taggedValue }}&lt;\/span&gt; &lt;\/template&gt;<\/code><\/pre>\n<h4>3. \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430<\/h4>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>: \u041a\u0430\u0436\u0434\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/strong>: \u041a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b\u044b \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c<\/strong>: \u0412\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u043f\u0441\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435<\/strong>: \u041b\u0435\u0433\u043a\u043e \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u0435\u043b\u043a\u0438\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/strong>: \u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u0437\u0430\u0431\u043b \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<\/li>\n<\/ol>\n<h4>4. \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432<\/h4>\n<pre><code class=\"javascript\">&lt;template&gt;   &lt;div&gt;     &lt;!-- \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0441\u0443\u043c\u043c\u0430 --&gt;     &lt;SumComponent :a=\"2\" :b=\"3\" \/&gt;      &lt;!-- \u0421\u0443\u043c\u043c\u0430 \u0441 \u0442\u0435\u0433\u043e\u043c --&gt;     &lt;SumComponentAndTag :a=\"2\" :b=\"3\" tag=\"result\" \/&gt;    &lt;\/div&gt; &lt;\/template&gt;  &lt;script setup&gt; import SumComponent from '.\/components\/SumComponent.vue'; import SumComponentAndTag from '.\/components\/SumComponentAndTag.vue'; &lt;\/script&gt;<\/code><\/pre>\n<h4>5. \u0418\u0442\u043e\u0433<\/h4>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u00a0useComposable\u00a0\u0432\u043e Vue 3 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u0438\u0431\u043a\u0438\u0435 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043f\u0440\u043e\u0449\u0430\u0442\u044c \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>Options API<\/h4>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h3>\n<ol>\n<li>\n<p><strong>\u0421\u043b\u043e\u0442\u044b<\/strong>: \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0442\u044c \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0438\u043a\u0441\u0438\u043d\u044b<\/strong>: \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u0438 \u043d\u0435\u044f\u0432\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u044b\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f\u043c\u0438<\/strong>: \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<\/strong>\u00a0\u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c DRY \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/strong>\u00a0\u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0433\u0438\u0431\u043a\u0438\u043c \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c.<\/p>\n<\/li>\n<li>\n<p><strong>Composition API<\/strong>\u00a0\u0432\u043e Vue \u2014 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432<\/strong>: \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430 \u043c\u0435\u043b\u043a\u0438\u0435, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441 \u043c\u0435\u0436\u0434\u0443 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c\u044e \u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0434\u0430.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/893370\/\"> https:\/\/habr.com\/ru\/articles\/893370\/<\/a><br \/><\/br><\/br><\/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-452762","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/452762","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=452762"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/452762\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=452762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=452762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=452762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}