{"id":324670,"date":"2021-06-09T21:00:25","date_gmt":"2021-06-09T21:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=324670"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=324670","title":{"rendered":"\u0418\u0437 Vue 2 \u043d\u0430 Vue 3 \u2013 Migration Helper"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>\u0411\u044b\u043b\u0430 \u0443 \u043c\u0435\u043d\u044f \u043a\u0443\u0440\u0441\u043e\u0432\u0430\u044f \u043f\u043e \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u0438 \u0440\u0435\u0448\u0438\u043b \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/www.npmjs.com\/package\/vue2-to-3\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/a> \u0438\u0437 Vue 2 (options-api) \u0432 Vue 3 (composition-api) \u0441 <strong>\u0430\u0432\u0442\u043e\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/strong> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%9A%D0%BE%D1%81%D0%B0%D1%80%D0%B0%D0%B9%D1%8E\" rel=\"noopener noreferrer nofollow\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u041a\u043e\u0441\u0430\u0440\u0430\u0439\u044e<\/a> \u043f\u043e \u043f\u043e\u0438\u0441\u043a\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0432 \u0442\u0435\u043c\u0435, \u043f\u043e\u044f\u0441\u043d\u044e, \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 <a href=\"https:\/\/v3.vuejs.org\/guide\/composition-api-introduction.html#reactive-variables-with-ref\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434<\/a> \u0441 options-api:<\/p>\n<pre><code class=\"javascript\">export default {   data () {     return {       foo: 0,       bar: 'hello',     }   },   watch: {     ...   },   methods: {     log(v) {       console.log(v);     },   },   mounted () {     this.log('Hello');   } }<\/code><\/pre>\n<p>\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0441 composition-api:<\/p>\n<pre><code class=\"javascript\">export default {   setup (props) {     const foo = reactive(0);     const bar = reactive('hello');      watch(...);      const log = (v) =&gt; { console.log(v); };      onMounted(() =&gt; { log('hello'); });      return {       foo,       bar,       log,     };   } }<\/code><\/pre>\n<h2>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/h2>\n<p>\u0414\u0430\u0431\u044b \u043d\u0435 \u043e\u0442\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u0441\u0430\u043c\u043e\u0439 \u0438\u0434\u0435\u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0439, \u043f\u043e\u043c\u0438\u043c\u043e \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 composition-api, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/strong>, \u0438 \u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435. \u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u043c\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438? \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u0442\u0430\u043a:<\/p>\n<p>\u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u2013 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0431\u043b\u043e\u043a\u043e\u0432 \u043a\u043e\u0434\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0437\u0430 \u043e\u0434\u0438\u043d \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, <strong>\u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e <\/strong>\u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0443\u0442 \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435!<\/p>\n<p>\u0411\u043b\u043e\u043a\u0430\u043c\u0438 \u043a\u043e\u0434\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c: \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 data, \u043c\u0435\u0442\u043e\u0434\u044b, \u0432\u043e\u0442\u0447\u0435\u0440\u044b, \u0445\u0443\u043a\u0438, \u0438 \u0432\u0441\u0435 \u0442\u043e, \u0438\u0437 \u0447\u0435\u0433\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Vue.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u0441\u044f \u043d\u0430 \u0441\u0447\u0451\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0431\u043b\u043e\u043a\u043e\u0432 \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0421 \u044d\u0442\u0438\u043c \u0432\u043e Vue \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 computed, method, hook, provide  \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0442\u043e \u043e\u043d\u043e \u043e\u0442 \u043d\u0438\u0445 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0430\u0432\u0435\u0448\u0435\u043d \u0432\u043e\u0442\u0447\u0435\u0440, \u0442\u043e \u0432\u043e\u0442\u0447\u0435\u0440 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"javascript\">data: () =&gt; ({   array: ['Hello', 'World'], \/\/ block 1 }), watch: {   array() { \/\/ block 2 (watch handler) depends on block 1     console.log('array changed');   }, }, computed: {   arrayCount() { \/\/ block 3     return this.array.length; \/\/ block 3 depends on block 1   }, }, methods: {   arrayToString() { \/\/ block 4     return this.array.join(' '); \/\/ block 4 depends on block 1   } }, <\/code><\/pre>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u043a\u043e\u0434\u0443 \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u0435-\u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u041a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438?<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043e\u0442 Vue, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0438 \u0442.\u0434. \u041e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>\u0412\u044b\u0434\u0435\u043b\u0438\u043c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u0433\u0434\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0430 \u0440\u0435\u0431\u0440\u0430\u043c\u0438 &#8212; \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435!<\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041a\u043e\u0441\u0430\u0440\u0430\u0439\u044e<\/h2>\n<p><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%9A%D0%BE%D1%81%D0%B0%D1%80%D0%B0%D0%B9%D1%8E\" rel=\"noopener noreferrer nofollow\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/a> \u043f\u043e\u0438\u0441\u043a\u0430&nbsp;\u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u0438&nbsp;\u0432 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0435. \u0417\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0432 \u0434\u0432\u0443\u0445 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u0445 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0433\u0440\u0430\u0444\u0430\u043c \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0433\u0438\u0438.<\/p>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u0431\u044b \u043d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/e-maxx.ru\/algo\/strong_connected_components\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 C<\/a> \u043d\u0430 TS \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c \ud83d\ude42<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043c\u044b \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u0430\u0432\u0435\u0442\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u0432\u044f\u0437\u044f\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0434\u0438\u043d\u043e\u043a\u0438\u043c \u0438 \u0431\u0435\u0437 \u043f\u0430\u0440\u044b, \u043c\u044b \u043e\u0442\u043d\u0435\u0441\u0435\u043c \u0435\u0433\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0431\u0443\u0434\u0443\u0449\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442 \u2013 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u0433\u0440\u0443\u043f\u043f\u0443 \u0432 \u043e\u0434\u043d\u0443 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432 options-api \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u0435\u0440\u0435\u0437 <\/em><code>this<\/code><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0433\u0440\u0443\u0441\u0442\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0441\u043a\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 .js \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">const splitter = \/this.[0-9a-zA-Z]{0,}\/ const splitterThis = 'this.'  export const findDepsByString = (   vueExpression: string,   instanceDeps: InstanceDeps ): ConnectionsType | undefined =&gt; {   return vueExpression     .match(splitter)     ?.map((match) =&gt; match.split(splitterThis)[1])     .filter((value) =&gt; instanceDeps[value])     .map((value) =&gt; value)<\/code><\/pre>\n<p>\u0414\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0441\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u043e\u0439 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0438\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 <code>this.<\/code> \ud83d\ude41<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043a\u043e\u0441\u0442\u044b\u043b\u044c\u043d\u044b\u0439:<\/p>\n<pre><code class=\"javascript\">export const findDeps = (   vueExpression: Noop,   instanceDeps: InstanceDeps ): ConnectionsType | undefined =&gt; {   const target = {}   const proxy = new Proxy(target, {   \/\/ \u043f\u0440\u043e\u043a\u0441\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430     get(target: any, name) {       target[name] = 'get'       return true     },     set(target: any, name) {       target[name] = 'set'       return true     }   })   try {     vueExpression.bind(proxy)() \/\/ \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u0441\u043a\u043e\u0443\u043f\u0435 \u043f\u0440\u043e\u043a\u0441\u0438     return Object.keys(target) || [] \/\/ \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u0440\u0438 this.   } catch (e) { \/\/ \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u0443     return findDepsByString(vueExpression.toString(), instanceDeps) || []   } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u043a\u0441\u0438 \u0432\u044b\u0448\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong> \u2013 <em>\u0430 \u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u0430\u043c \u043f\u0435\u043d\u0442\u0430\u0433\u043e\u043d \u0432\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u0442\u0435?<\/em><\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0437\u0430\u0447\u0435\u043c \u043c\u044b \u0442\u0443\u0442 \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c: \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0440\u0430\u0437\u0431\u0438\u0442\u044b\u0435 \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 composition-api, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0435\u0442\u0435 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0443\u043c\u0435\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u0442\u0440\u043e\u043a, \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u0438\u0445 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c, <em>\u043a\u043e\u0434\u043e\u0432\u043e\u043c<\/em>, \u0432\u0438\u0434\u0435. \u0412\u043e\u0442 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">const toString = (item: any): string =&gt; {   if (Array.isArray(item)) {     \/\/ array     const builder: string[] = []     item.forEach((_) =&gt; {       builder.push(toString(_)) \/\/ wow, it's recursion!     })     return `[${builder.join(',')}]`   }    if (typeof item === 'object' &amp;&amp; item !== null) {     \/\/ object     const builder: string[] = []     Object.keys(item).forEach((name) =&gt; {       builder.push(`${name}: ${toString(item[name])}`) \/\/ wow, it's recursion!     })     return `{${builder.join(',')}}`   }    if (typeof item === 'string') {     \/\/ string     return `'${item}'`   }    return item \/\/ number, float, boolean }  \/\/ Example console.log(toString([{ foo: { bar: 'hello', baz: 'hello', }}, 1]); \/\/ [{foo:{bar: 'hello',baz: 'hello'}},1] \u2013 \u0442.\u0435. \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0432 \u043a\u043e\u0434\u0435<\/code><\/pre>\n<p>\u041f\u0440\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 <s>\u0433\u043e\u0432\u043d\u043e<\/s>\u043a\u043e\u0434 \u044f \u0442\u0430\u043a\u0442\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u043c\u043e\u043b\u0447\u0443 \ud83d\ude42<\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 <code>fs.writeFile()<\/code> \u0432 \u043d\u043e\u0434\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b<\/h2>\n<p>\u0421\u043e\u0431\u0440\u0430\u0432 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432 \u043f\u0430\u043a\u0435\u0442, <s>\u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0432<\/s> \u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0432, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c <a href=\"https:\/\/www.npmjs.com\/package\/vue2-to-3\" rel=\"noopener noreferrer nofollow\">\u043f\u0430\u043a\u0435\u0442 vue2-to-3<\/a> \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e (\u0438\u043d\u0430\u0447\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c!<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 <code>HelloWorld.js<\/code>:<\/p>\n<pre><code class=\"javascript\">export default {   name: 'HelloWorld',   data: () =&gt; ({     some: 0,     another: 0,     foo: ['potato'],   }),   methods: {     somePlus() {       this.some++;     },     anotherPlus() {       this.another++;     },   }, };<\/code><\/pre>\n<p>\u041f\u0438\u0448\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>migrate .\/HelloWorld.js<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 3 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">\/\/ CompositionSome.js import { reactive } from 'vue';  export const CompositionSome = () =&gt; {   const some = reactive(0);   const somePlus = () =&gt; { some++ };   return {     some,     somePlus,   }; };  \/\/ CompositionAnother.js import { reactive } from 'vue';  export const CompositionAnother = () =&gt; {   const another = reactive(0);   const anotherPlus = () =&gt; { another++ };   return {     another,     anotherPlus,   }; };  \/\/ HelloWorld.js import { reactive } from 'vue';  import { CompositionSome } from '.\/CompositionSome.js' import { CompositionAnother } from '.\/CompositionAnother.js'  export default {   name: 'HelloWorld',   setup() {     const _CompositionSome = CompositionSome();     const _CompositionAnother = CompositionAnother();     const foo = reactive(['potato']);     return {       foo,       some: _CompositionSome.some,       somePlus: _CompositionSome.somePlus,       another: _CompositionAnother.another,       anotherPlus: _CompositionAnother.anotherPlus,     };   }, };<\/code><\/pre>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0435\u0449\u0451 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0430\u0433\u0438 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0435 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043f\u0443\u0442\u044f\u043c\u0438 (\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f linux \u0441\u0438\u0441\u0442\u0435\u043c)<\/p>\n<p> \u0412 \u043f\u043b\u0430\u043d\u0430\u0445 \u0437\u0430\u043f\u0438\u043b\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f <code>single-file-components<\/code> \u0438 <code>.ts<\/code> \u0444\u0430\u0439\u043b\u043e\u0432 (\u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f <code>.js<\/code>)<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p><a href=\"https:\/\/www.npmjs.com\/package\/vue2-to-3\" rel=\"noopener noreferrer nofollow\">npm<\/a>, <a href=\"https:\/\/github.com\/IldarDavletyarov\/vue2-to-3\" rel=\"noopener noreferrer nofollow\"> git<\/a><\/p>\n<\/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\/562016\/\"> https:\/\/habr.com\/ru\/post\/562016\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<h2>\u041f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h2>\n<p>\u0411\u044b\u043b\u0430 \u0443 \u043c\u0435\u043d\u044f \u043a\u0443\u0440\u0441\u043e\u0432\u0430\u044f \u043f\u043e \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u0438 \u0440\u0435\u0448\u0438\u043b \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/www.npmjs.com\/package\/vue2-to-3\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438<\/a> \u0438\u0437 Vue 2 (options-api) \u0432 Vue 3 (composition-api) \u0441 <strong>\u0430\u0432\u0442\u043e\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/strong> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%9A%D0%BE%D1%81%D0%B0%D1%80%D0%B0%D0%B9%D1%8E\" rel=\"noopener noreferrer nofollow\">\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u041a\u043e\u0441\u0430\u0440\u0430\u0439\u044e<\/a> \u043f\u043e \u043f\u043e\u0438\u0441\u043a\u0443 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0432 \u0442\u0435\u043c\u0435, \u043f\u043e\u044f\u0441\u043d\u044e, \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 <a href=\"https:\/\/v3.vuejs.org\/guide\/composition-api-introduction.html#reactive-variables-with-ref\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434<\/a> \u0441 options-api:<\/p>\n<pre><code class=\"javascript\">export default {   data () {     return {       foo: 0,       bar: 'hello',     }   },   watch: {     ...   },   methods: {     log(v) {       console.log(v);     },   },   mounted () {     this.log('Hello');   } }<\/code><\/pre>\n<p>\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a \u0441 composition-api:<\/p>\n<pre><code class=\"javascript\">export default {   setup (props) {     const foo = reactive(0);     const bar = reactive('hello');      watch(...);      const log = (v) =&gt; { console.log(v); };      onMounted(() =&gt; { log('hello'); });      return {       foo,       bar,       log,     };   } }<\/code><\/pre>\n<h2>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/h2>\n<p>\u0414\u0430\u0431\u044b \u043d\u0435 \u043e\u0442\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u0441\u0430\u043c\u043e\u0439 \u0438\u0434\u0435\u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0439, \u043f\u043e\u043c\u0438\u043c\u043e \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 composition-api, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/strong>, \u0438 \u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435. \u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u043c\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438? \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u0442\u0430\u043a:<\/p>\n<p>\u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u2013 \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0431\u043b\u043e\u043a\u043e\u0432 \u043a\u043e\u0434\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0437\u0430 \u043e\u0434\u0438\u043d \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, <strong>\u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e <\/strong>\u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0443\u0442 \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435!<\/p>\n<p>\u0411\u043b\u043e\u043a\u0430\u043c\u0438 \u043a\u043e\u0434\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c: \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 data, \u043c\u0435\u0442\u043e\u0434\u044b, \u0432\u043e\u0442\u0447\u0435\u0440\u044b, \u0445\u0443\u043a\u0438, \u0438 \u0432\u0441\u0435 \u0442\u043e, \u0438\u0437 \u0447\u0435\u0433\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Vue.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c\u0441\u044f \u043d\u0430 \u0441\u0447\u0451\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0431\u043b\u043e\u043a\u043e\u0432 \u043a\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0421 \u044d\u0442\u0438\u043c \u0432\u043e Vue \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 computed, method, hook, provide  \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0442\u043e \u043e\u043d\u043e \u043e\u0442 \u043d\u0438\u0445 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0430\u0432\u0435\u0448\u0435\u043d \u0432\u043e\u0442\u0447\u0435\u0440, \u0442\u043e \u0432\u043e\u0442\u0447\u0435\u0440 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435 \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"javascript\">data: () =&gt; ({   array: ['Hello', 'World'], \/\/ block 1 }), watch: {   array() { \/\/ block 2 (watch handler) depends on block 1     console.log('array changed');   }, }, computed: {   arrayCount() { \/\/ block 3     return this.array.length; \/\/ block 3 depends on block 1   }, }, methods: {   arrayToString() { \/\/ block 4     return this.array.join(' '); \/\/ block 4 depends on block 1   } }, <\/code><\/pre>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0439\u0442\u0438\u0441\u044c \u043f\u043e \u043a\u043e\u0434\u0443 \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u0435-\u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u041a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438?<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043e\u0442 Vue, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0438 \u0442.\u0434. \u041e\u0441\u0442\u0430\u0432\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>\u0412\u044b\u0434\u0435\u043b\u0438\u043c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u0433\u0434\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0430 \u0440\u0435\u0431\u0440\u0430\u043c\u0438 &#8212; \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438. \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435!<\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041a\u043e\u0441\u0430\u0440\u0430\u0439\u044e<\/h2>\n<p><a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC_%D0%9A%D0%BE%D1%81%D0%B0%D1%80%D0%B0%D0%B9%D1%8E\" rel=\"noopener noreferrer nofollow\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/a> \u043f\u043e\u0438\u0441\u043a\u0430&nbsp;\u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u0438&nbsp;\u0432 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0435. \u0417\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u0432 \u0434\u0432\u0443\u0445 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u0445 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043f\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u0433\u0440\u0430\u0444\u0430\u043c \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0433\u0438\u0438.<\/p>\n<p>\u041d\u0438\u043a\u043e\u0433\u0434\u0430 \u0431\u044b \u043d\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/e-maxx.ru\/algo\/strong_connected_components\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 C<\/a> \u043d\u0430 TS \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c \ud83d\ude42<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043c\u044b \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u0430\u0432\u0435\u0442\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u0432\u044f\u0437\u044f\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0434\u0438\u043d\u043e\u043a\u0438\u043c \u0438 \u0431\u0435\u0437 \u043f\u0430\u0440\u044b, \u043c\u044b \u043e\u0442\u043d\u0435\u0441\u0435\u043c \u0435\u0433\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0431\u0443\u0434\u0443\u0449\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442 \u2013 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u0433\u0440\u0443\u043f\u043f\u0443 \u0432 \u043e\u0434\u043d\u0443 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0432 options-api \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u0435\u0440\u0435\u0437 <\/em><code>this<\/code><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0433\u0440\u0443\u0441\u0442\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0441\u043a\u0430\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 .js \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">const splitter = \/this.[0-9a-zA-Z]{0,}\/ const splitterThis = 'this.'  export const findDepsByString = (   vueExpression: string,   instanceDeps: InstanceDeps ): ConnectionsType | undefined =&gt; {   return vueExpression     .match(splitter)     ?.map((match) =&gt; match.split(splitterThis)[1])     .filter((value) =&gt; instanceDeps[value])     .map((value) =&gt; value)<\/code><\/pre>\n<p>\u0414\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0441\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u043e\u0439 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0438\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 <code>this.<\/code> \ud83d\ude41<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u043a\u043e\u0441\u0442\u044b\u043b\u044c\u043d\u044b\u0439:<\/p>\n<pre><code class=\"javascript\">export const findDeps = (   vueExpression: Noop,   instanceDeps: InstanceDeps ): ConnectionsType | undefined =&gt; {   const target = {}   const proxy = new Proxy(target, {   \/\/ \u043f\u0440\u043e\u043a\u0441\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430     get(target: any, name) {       target[name] = 'get'       return true     },     set(target: any, name) {       target[name] = 'set'       return true     }   })   try {     vueExpression.bind(proxy)() \/\/ \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u0441\u043a\u043e\u0443\u043f\u0435 \u043f\u0440\u043e\u043a\u0441\u0438     return Object.keys(target) || [] \/\/ \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u0440\u0438 this.   } catch (e) { \/\/ \u043f\u0440\u0438 \u043e\u0448\u0438\u0431\u043a\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0441\u043f\u043e\u0441\u043e\u0431\u0443     return findDepsByString(vueExpression.toString(), instanceDeps) || []   } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0440\u043e\u043a\u0441\u0438 \u0432\u044b\u0448\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>\u0441\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong> \u2013 <em>\u0430 \u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u0430\u043c \u043f\u0435\u043d\u0442\u0430\u0433\u043e\u043d \u0432\u0437\u043b\u0430\u043c\u044b\u0432\u0430\u0435\u0442\u0435?<\/em><\/p>\n<\/li>\n<\/ul>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043a\u043e\u0434\u0430<\/h2>\n<p>\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0437\u0430\u0447\u0435\u043c \u043c\u044b \u0442\u0443\u0442 \u0441\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c: \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0440\u0430\u0437\u0431\u0438\u0442\u044b\u0435 \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 composition-api, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0447\u0435\u0442\u0435 \u0431\u0443\u0434\u0443\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0443\u043c\u0435\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441\u0442\u0440\u043e\u043a, \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u0438\u0445 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c, <em>\u043a\u043e\u0434\u043e\u0432\u043e\u043c<\/em>, \u0432\u0438\u0434\u0435. \u0412\u043e\u0442 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">const toString = (item: any): string =&gt; {   if (Array.isArray(item)) {     \/\/ array     const builder: string[] = []     item.forEach((_) =&gt; {       builder.push(toString(_)) \/\/ wow, it's recursion!     })     return `[${builder.join(',')}]`   }    if (typeof item === 'object' &amp;&amp; item !== null) {     \/\/ object     const builder: string[] = []     Object.keys(item).forEach((name) =&gt; {       builder.push(`${name}: ${toString(item[name])}`) \/\/ wow, it's recursion!     })     return `{${builder.join(',')}}`   }    if (typeof item === 'string') {     \/\/ string     return `'${item}'`   }    return item \/\/ number, float, boolean }  \/\/ Example console.log(toString([{ foo: { bar: 'hello', baz: 'hello', }}, 1]); \/\/ [{foo:{bar: 'hello',baz: 'hello'}},1] \u2013 \u0442.\u0435. \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u0432 \u043a\u043e\u0434\u0435<\/code><\/pre>\n<p>\u041f\u0440\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 <s>\u0433\u043e\u0432\u043d\u043e<\/s>\u043a\u043e\u0434 \u044f \u0442\u0430\u043a\u0442\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u043c\u043e\u043b\u0447\u0443 \ud83d\ude42<\/p>\n<p>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 <code>fs.writeFile()<\/code> \u0432 \u043d\u043e\u0434\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b<\/h2>\n<p>\u0421\u043e\u0431\u0440\u0430\u0432 \u0432\u0441\u0451 \u044d\u0442\u043e \u0432 \u043f\u0430\u043a\u0435\u0442, <s>\u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0432<\/s> \u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0432, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c <a href=\"https:\/\/www.npmjs.com\/package\/vue2-to-3\" rel=\"noopener noreferrer nofollow\">\u043f\u0430\u043a\u0435\u0442 vue2-to-3<\/a> \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e (\u0438\u043d\u0430\u0447\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c) \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c!<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 <code>HelloWorld.js<\/code>:<\/p>\n<pre><code class=\"javascript\">export default {   name: 'HelloWorld',   data: () =&gt; ({     some: 0,     another: 0,     foo: ['potato'],   }),   methods: {     somePlus() {       this.some++;     },     anotherPlus() {       this.another++;     },   }, };<\/code><\/pre>\n<p>\u041f\u0438\u0448\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>migrate .\/HelloWorld.js<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 3 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">\/\/ CompositionSome.js import { reactive } from 'vue';  export const CompositionSome = () =&gt; {   const some = reactive(0);   const somePlus = () =&gt; { some++ };   return {     some,     somePlus,   }; };  \/\/ CompositionAnother.js import { reactive } from 'vue';  export const CompositionAnother = () =&gt; {   const another = reactive(0);   const anotherPlus = () =&gt; { another++ };   return {     another,     anotherPlus,   }; };  \/\/ HelloWorld.js import { reactive } from 'vue';  import { CompositionSome } from '.\/CompositionSome.js' import { CompositionAnother } from '.\/CompositionAnother.js'  export default {   name: 'HelloWorld',   setup() {     const _CompositionSome = CompositionSome();     const _CompositionAnother = CompositionAnother();     const foo = reactive(['potato']);     return {       foo,       some: _CompositionSome.some,       somePlus: _CompositionSome.somePlus,       another: _CompositionAnother.another,       anotherPlus: _CompositionAnother.anotherPlus,     };   }, };<\/code><\/pre>\n<h2>\u0418\u0442\u043e\u0433\u043e<\/h2>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0435\u0449\u0451 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0430\u0433\u0438 \u0441\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0435 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043f\u0443\u0442\u044f\u043c\u0438 (\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0444\u0430\u0442\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f linux \u0441\u0438\u0441\u0442\u0435\u043c)<\/p>\n<p> \u0412 \u043f\u043b\u0430\u043d\u0430\u0445 \u0437\u0430\u043f\u0438\u043b\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f <code>single-file-components<\/code> \u0438 <code>.ts<\/code> \u0444\u0430\u0439\u043b\u043e\u0432 (\u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f <code>.js<\/code>)<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p><a href=\"https:\/\/www.npmjs.com\/package\/vue2-to-3\" rel=\"noopener noreferrer nofollow\">npm<\/a>, <a href=\"https:\/\/github.com\/IldarDavletyarov\/vue2-to-3\" rel=\"noopener noreferrer nofollow\"> git<\/a><\/p>\n<\/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\/562016\/\"> https:\/\/habr.com\/ru\/post\/562016\/<\/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-324670","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324670","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=324670"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/324670\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=324670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=324670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=324670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}