{"id":274231,"date":"2016-02-13T22:56:02","date_gmt":"2016-02-13T19:56:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=274231"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=274231","title":{"rendered":"\u041f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u041c\u0430\u0442\u0440\u0435\u0448\u043a\u0438: \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u043e\u0443\u0442\u0438\u043d\u0433"},"content":{"rendered":"<p>       <a href=\"http:\/\/output.jsbin.com\/pigihe\/10\/#!\/foo\/bar\/baz\/\">\u0414\u0435\u043c\u043e<\/a><br \/>  <a href=\"https:\/\/github.com\/matreshkajs\/matreshka-router\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a><\/p>\n<h1>tl;dr<\/h1>\n<p>  \u041f\u043b\u0430\u0433\u0438\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u0443\u0441\u043a\u0430 \u0443\u0440\u043b\u0430.<\/p>\n<pre><code>this.initRouter('\/a\/b\/c\/'); this.a = 'foo'; this.b = 'bar'; this.c = 'baz'  \/\/ location.hash \u0442\u0435\u043f\u0435\u0440\u044c #!\/foo\/bar\/baz\/<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f History API \u0432\u043c\u0435\u0441\u0442\u043e <code>location.hash<\/code>, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 <code>&quot;history&quot;<\/code> \u0432\u0442\u043e\u0440\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c.<\/p>\n<pre><code>this.initRouter('\/a\/b\/c\/', 'history');<\/code><\/pre>\n<p><a name=\"habracut\"><\/a><br \/>  \u0421\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0440\u043e\u043d\u0442-\u0435\u043d\u0434 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430. \u0412\u043e\u043f\u0440\u043e\u0441 \u201c\u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u041c\u0430\u0442\u0440\u0435\u0448\u043a\u0435 \u0440\u043e\u0443\u0442\u0435\u0440\u201d \u0437\u0432\u0443\u0447\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0447\u0430\u0441\u0442\u043e, \u043d\u0430 \u0447\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b \u043e\u0434\u0438\u043d \u043e\u0442\u0432\u0435\u0442: \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u044e\u0442 \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u0438 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043b\u0443\u0448\u0435, \u0447\u0435\u043c \u043d\u0435\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u201c\u043c\u0435\u0441\u0442\u044f\u0447\u043a\u043e\u0432\u043e\u0433\u043e\u201d \u0440\u043e\u0443\u0442\u0435\u0440\u0430. \u042d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u0439 FAQ \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430 Director. \u041d\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0448\u043b\u043e.<\/p>\n<p>  \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u201c\u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0439\u201d \u0440\u043e\u0443\u0442\u0438\u043d\u0433? \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e (\u0440\u043e\u0443\u0442) \u0438 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0443\u0440\u043b\u0430 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c.<\/p>\n<pre><code>route('books\/:id', id =&gt; {     \/\/ \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e });<\/code><\/pre>\n<p>  Matreshka Router \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u041e\u043d \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u044f\u043c \u041c\u0430\u0442\u0440\u0435\u0448\u043a\u0438, \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0443\u0442\u0438 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430. <\/p>\n<p>  <strong>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440:<\/strong> \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u043e\u0432 \u0438 \u0431\u0435\u0441\u043f\u0440\u0435\u0446\u0435\u0434\u0435\u043d\u0442\u0435\u043d. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0442\u0430\u0432\u044f\u0442 \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u0435\u0441\u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p>  \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u0432\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0443\u0440\u043b\u0430 (\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438 <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/Window\/location\">hash<\/a>, \u0438 <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/History_API\">HTML5 History<\/a>) \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c.<\/p>\n<p>  \u0421\u043a\u0430\u0436\u0435\u043c, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>&quot;x&quot;<\/code> \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e <code>location.hash<\/code>, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>&quot;y&quot;<\/code> \u2014 \u0441\u043e \u0432\u0442\u043e\u0440\u043e\u0439.<\/p>\n<pre><code>this.initRouter(&quot;\/x\/y\/&quot;);<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435..<\/p>\n<pre><code>this.x = 'foo'; this.y = 'bar';<\/code><\/pre>\n<p>  \u2026 \u0425\u0435\u0448 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043d\u0430 <code>#!\/foo\/bar\/<\/code><\/p>\n<p>  \u0418 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e \u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u0435\u043b\u043e\u043a \u201c\u0432\u043f\u0435\u0440\u0435\u0434\u201d \u0438 \u201c\u043d\u0430\u0437\u0430\u0434\u201c \u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u0430\u0434\u0440\u0435\u0441, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<pre><code>location.hash = '#!\/baz\/qux\/';  console.log(this.x, this.y); \/\/ \u2018bar\u2019, \u2018qux\u2019<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438 \u0432\u0441\u0435\u0433\u0434\u0430, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/ru.matreshka.io\/#!Matreshka-on\">on<\/a>.<\/p>\n<pre><code>this.on('change:x', handler);<\/code><\/pre>\n<p>  \u0412 \u043c\u0435\u0442\u043e\u0434 <code>initRouter<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u043e \u201c\u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430\u043c\u0438\u201d, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0447\u0430\u0441\u0442\u0438 \u0443\u0440\u043b\u0430.<\/p>\n<pre><code>this.initRouter('\/x\/*\/y');<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0445\u0435\u0448 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u0430\u043a <code>#!\/foo\/bar\/baz\/<\/code>, \u0442\u043e <code>this.x<\/code> \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u044b\u043c <code>&quot;foo&quot;<\/code>, <code>this.y<\/code> \u2014 <code>&quot;baz&quot;<\/code>.<\/p>\n<p>  \u0422\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u043e\u0434\u043d\u0443 \u0447\u0430\u0441\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430, \u0434\u0440\u0443\u0433\u043e\u0439 \u2014 \u0434\u0440\u0443\u0433\u0443\u044e.<\/p>\n<p>  <strong>class1.js<\/strong><\/p>\n<pre><code>this.initRouter('\/x\/*\/');<\/code><\/pre>\n<p>  <strong>class2.js<\/strong><\/p>\n<pre><code>this.initRouter('\/*\/y\/');<\/code><\/pre>\n<p>  \u0412\u0430\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<p>  <strong>1.<\/strong> \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u0434\u0438\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430\u0434\u0440\u0435\u0441 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>initRouter<\/code>. \u0418\u043d\u0430\u0447\u0435 \u2014 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0443\u0442\u0438.<\/p>\n<pre><code>this.x = 'foo';  this.initRouter('\/x\/y\/');<\/code><\/pre>\n<p>  <strong>2.<\/strong> \u0415\u0441\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 \u0440\u043e\u0443\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043b\u0436\u0438\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u0441\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u043e\u0443\u0442\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>null<\/code>.<\/p>\n<pre><code>this.initRouter('\/x\/y\/z\/u\/');  this.y = null; \/\/ \u0443\u0441\u0442\u0432\u043d\u043e\u0432\u0438\u0442 this.z \u0438 this.u \u0442\u043e\u0436\u0435 \u0432 null<\/code><\/pre>\n<p>  \u041f\u0443\u0441\u043a\u0430\u0439 \u0432\u0430\u0441 \u043d\u0435 \u043f\u0443\u0433\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0418\u0434\u0435\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0443\u0440\u043b\u0430 \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u043d\u044b\u043c\u0438. \u0411\u044b\u043b\u043e \u0431\u044b \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>&quot;z&quot;<\/code> \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <code>&quot;foo&quot;<\/code> \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u044d\u0442\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c.<\/p>\n<h2>HTML5 History API<\/h2>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0445\u0435\u0448 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430, \u043f\u043b\u0430\u0433\u0438\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 HTML5 History. \u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434 <code>initRoute<\/code> \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>type<\/code> \u0440\u0430\u0432\u043d\u044b\u0439 <code>&quot;history&quot;<\/code> (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, <code>type = &quot;hash&quot;<\/code>).<\/p>\n<pre><code>this.initRouter('\/x\/y\/z\/', 'history');<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/h2>\n<p>  \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u041c\u0430\u0442\u0440\u0435\u0448\u043a\u0438 (\u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f, \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u043f\u0440.) \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/ru.matreshka.io\/#!Matreshka-on\">on<\/a>. <\/p>\n<pre><code>\/\/ \u0435\u0441\u043b\u0438 this - \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u041c\u0430\u0442\u0440\u0435\u0448\u043a\u0438 this.on('something', handler);  \/\/ \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 var obj = {}; MK.on(obj, 'something', handler);<\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043a\u0440\u044b\u0442\u044b \u043f\u043e\u0434 \u0444\u043b\u0430\u0436\u043a\u043e\u043c \u201c\u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0439 \u0440\u0435\u0436\u0438\u043c\u201d \u0432 <a href=\"https:\/\/ru.matreshka.io\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>  \u0422\u0430\u043a\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0431\u043e\u0448\u043b\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u0438 \u044d\u0442\u043e\u0442 \u043f\u043b\u0430\u0433\u0438\u043d: \u043a\u0440\u043e\u043c\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430, \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0435\u0441\u0442\u044c \u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 \u043c\u0435\u0442\u043e\u0434\u0430 <code>initRouter<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<pre><code>var obj = {}; MK.initRouter(obj, '\/a\/b\/c\/');  obj.a = 'foo'; obj.b = 'bar'; obj.c = 'baz';<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u042f\u0434\u0440\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Matreshka.Router<\/code>. \u0415\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442: \u0442\u0438\u043f \u0440\u043e\u0443\u0442\u0435\u0440\u0430 <code>(&quot;hash&quot;<\/code>, <code>&quot;history&quot;<\/code> \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443).<\/p>\n<p>  \u041f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Matreshka.Router<\/code> \u0441 \u0442\u0438\u043f\u0430\u043c\u0438 <code>hash<\/code> \u0438 <code>history<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 <code>Matreshka.Router.hash<\/code> \u0438 <code>Matreshka.Router.history<\/code> (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0431\u0435\u0437 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442). \u0414\u043b\u044f \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d, \u0442. \u0435, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 \u0441 \u0442\u0438\u043f\u043e\u043c <code>hash<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f <code>Matreshka.Router.hash<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430. \u0422\u0430\u043a\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0443\u0440\u043b\u0430, \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u044f \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438. \u041e\u0431\u044a\u0435\u043a\u0442\u044b, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c.<\/p>\n<p>  &quot;\u041a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435&quot; \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b <code>Matreshka.Router<\/code> \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u043d\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0438 \u043d\u0430 <code>hash<\/code> \u0438 \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 <code>pushState<\/code>.<\/p>\n<p>  \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <code>Router<\/code> \u0438\u043c\u0435\u044e\u0442 \u0442\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<p>  <code>path<\/code> \u2014 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0440\u043b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>\/foo\/bar\/baz\/<\/code>.<\/p>\n<p>  <code>hashPath<\/code> \u2014 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0436\u0435\u0434\u0436\u0438\u0442 path, \u0441 \u0434\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u043a \u043d\u0435\u0439 hashbang, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>#!\/foo\/bar\/baz\/<\/code><\/p>\n<p>  <code>parts<\/code> \u2014 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0443\u0441\u043e\u0447\u043a\u0438 \u043f\u0443\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>[\u2018foo\u2019, \u2018bar\u2019, \u2018baz\u2019]<\/code>.<\/p>\n<p>  \u0412\u0441\u0435 \u0442\u0440\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/ru.matreshka.io\/#!Matreshka-linkProps\">linkProps<\/a>, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435:<\/p>\n<pre><code>Matreshka.Router.hash.path = '\/yo\/man\/';<\/code><\/pre>\n<p>  \u2026 \u0418 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430<\/p>\n<p>  <code>subscribe(object, route)<\/code> \u2014 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445.<\/p>\n<p>  <code>init()<\/code> \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043b\u0435\u043d\u0438\u0432\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <code>subscribe<\/code> (\u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435\u0442 \u043d\u0443\u0436\u0434\u044b).<\/p>\n<pre><code>var customRouter = new Matreshka.Router(),     object = {         a: 'foo',         b: 'bar'     };  customRouter.subscribe(object, '\/a\/b\/');  console.log(customRouter.path); \/\/ \/foo\/bar\/<\/code><\/pre>\n<p>  \u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u0430.                 <\/p>\n<div class=\"clear\"><\/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:\/\/habrahabr.ru\/post\/277171\/\"> https:\/\/habrahabr.ru\/post\/277171\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <a href=\"http:\/\/output.jsbin.com\/pigihe\/10\/#!\/foo\/bar\/baz\/\">\u0414\u0435\u043c\u043e<\/a><br \/>  <a href=\"https:\/\/github.com\/matreshkajs\/matreshka-router\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a><\/p>\n<h1>tl;dr<\/h1>\n<p>  \u041f\u043b\u0430\u0433\u0438\u043d \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u0443\u0441\u043a\u0430 \u0443\u0440\u043b\u0430.<\/p>\n<pre><code>this.initRouter('\/a\/b\/c\/'); this.a = 'foo'; this.b = 'bar'; this.c = 'baz'  \/\/ location.hash \u0442\u0435\u043f\u0435\u0440\u044c #!\/foo\/bar\/baz\/<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f History API \u0432\u043c\u0435\u0441\u0442\u043e <code>location.hash<\/code>, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 <code>&quot;history&quot;<\/code> \u0432\u0442\u043e\u0440\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c.<\/p>\n<pre><code>this.initRouter('\/a\/b\/c\/', 'history');<\/code><\/pre>\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-274231","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274231","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=274231"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274231\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}