{"id":312173,"date":"2021-01-14T01:01:23","date_gmt":"2021-01-13T17:01:23","guid":{"rendered":"http:\/\/4563.org\/?p=312173"},"modified":"2021-01-14T01:01:23","modified_gmt":"2021-01-13T17:01:23","slug":"%e8%af%b7%e6%95%99%e4%b8%aa%e5%89%8d%e7%ab%af-vuerouter-%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=312173","title":{"rendered":"\u8bf7\u6559\u4e2a\u524d\u7aef vueRouter \u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e2a\u524d\u7aef vueRouter \u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : muunala10221 <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u6211\u6709\u4e24\u4e2a\u8def\u7531 A \u548c B\uff0c\u4e0b\u7ea7\u6709\u5f88\u591a\u540d\u5b57\u76f8\u540c\u7684\u7ec4\u4ef6.<br \/>\u5047\u8bbe\u6211\u5728 B \u9875\u9762\u5207\u6362\uff0c$router.push \u4e00\u4e2a A \u548c B \u7684 children \u4e0b\u76f8\u540c\u540d\u5b57\u7684\u7ec4\u4ef6\uff0c\u5c31\u4f1a\u8df3\u8f6c\u5230 A \u7684\u4e0b\u9762\uff0c\u6709\u4ec0\u4e48\u529e\u6cd5\u53ef\u4ee5\u89e3\u51b3\u5417\uff1f      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>13<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5037600\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Tlin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bf4\u7684\u6709\u70b9\u61f5\u3002\u4f60\u662f A \u3001B \u9875\u9762\u90fd\u662f\u7528\u76f8\u540c\u7684\u7ec4\u4ef6\uff0c\u4f46\u662f B \u9875\u9762\u8def\u7531 push \u540e\u4f1a\u8df3\u5230 A \u9875\u9762\uff1f push \u91cc\u9762\u7684\u53c2\u6570\u662f\u4e00\u4e9b\u8def\u7531\u4fe1\u606f\u914d\u7f6e\uff0c\u770b\u770b\u6709\u9519\u6ca1\uff0c\u6b64\u5916\u770b\u5f15\u5165\u7684\u7ec4\u4ef6\u91cc\u9762\u770b\u6709\u6ca1\u6709\u8def\u7531\u8df3\u8f6c\uff0c\u901a\u5e38 A \u5f15\u5165\u7ec4\u4ef6\u8ddf B \u5f15\u5165\u7ec4\u4ef6\u4e0d\u51b2\u7a81                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037601\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Carseason <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7edd\u5bf9\u8def\u5f84\u8df3\u8f6c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037602\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : muunala10221 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Tlin \u4e0d\u597d\u610f\u601d \u6ca1\u8868\u8fbe\u6e05\u695a \/a\/1 \/b\/1 \u5047\u5982\u6211\u5f53\u524d\u5904\u4e8e \/b \u4e0b \u6211\u60f3\u8df3\u8f6c\u5230 \/b\/1 \u8fd9\u65f6\u5019\u6211$router.push(name : 1) \u5c31\u4f1a\u8df3\u8f6c\u5230 \/a\/1 \u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037603\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : muunala10221 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Carseason \u6211\u67e5\u4e00\u4e0b \u611f\u8c22\u54c8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037604\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xingyuc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             name \u533a\u5206\u6216\u8005\u5199\u5168\u8def\u5f84                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037605\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Tlin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u5b98\u7f51\u7684\u7f16\u7a0b\u5f0f\u5bfc\u822a\u540e\u9762\u7684\u4e00\u53e5\u8bdd\u201c\u6ce8\u610f\uff1a \u5982\u679c\u76ee\u7684\u5730\u548c\u5f53\u524d\u8def\u7531\u76f8\u540c\uff0c\u53ea\u6709\u53c2\u6570\u53d1\u751f\u4e86\u6539\u53d8 (\u6bd4\u5982\u4ece\u4e00\u4e2a\u7528\u6237\u8d44\u6599\u5230\u53e6\u4e00\u4e2a \/users\/1 -&gt; \/users\/2)\uff0c\u4f60\u9700\u8981\u4f7f\u7528 beforeRouteUpdate \u6765\u54cd\u5e94\u8fd9\u4e2a\u53d8\u5316 (\u6bd4\u5982\u6293\u53d6\u7528\u6237\u4fe1\u606f)\u3002\u201d<br \/>\u5f53\u7136\u4f60\u53ef\u4ee5\u8bd5\u8bd5\u7edd\u5bf9\u8def\u5f84<\/p>\n<p>\u53ef\u4ee5\u8f6c\u53d8\u7b56\u7565\uff0c\u5d4c\u5957\u8def\u7531<br \/>https:\/\/router.vuejs.org\/zh\/guide\/essentials\/nested-routes.html                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037606\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : OHyn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             router.push \uff08 path\uff1a\u2018xxxxx\u2019\uff09\u7528\u8fd9\u4e2a API \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037607\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wunonglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u95ee\u9898\u548c\u6211\u5f53\u5e74\u5728 sf \u7684\u95ee\u7684\u95ee\u9898\u4e00\u6837\u3002<\/p>\n<p>https:\/\/segmentfault.com\/q\/1010000017007660?_ea=13033647<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\u662f\u53ea\u80fd\u662f\u7528\u7edd\u5bf9\u8def\u5f84\u3002\u6240\u4ee5\u9274\u4e8e\u4e00\u4e9b\u95ee\u9898\u4ee5\u53ca\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u8df3\u5751\u5230 ng \u4e86\u3002<\/p>\n<p>\u4e16\u95f4\u7f8e\u597d                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037608\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wunonglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b89\u5229\u4e0b ng \u7684\u5bfc\u822a\u65b9\u6cd5<br \/>&#8220;`<br \/>\/\/ http:\/\/127.0.0.1\/user\/1?page=1#header<br \/>\/\/ params \u7684\u8bdd\uff0c\u50cf\u8fd9\u4e2a id\uff0c\u653e\u6570\u503c\u540e\u9762\u5c31\u884c\u4e86<br \/>this.Router.navigate([&#8216;\/user&#8217;, id], {<br \/> \/\/ \u76f8\u5bf9\u4e8e\u5f53\u524d\u8def\u7531\u5bfc\u822a\uff0c\u53bb\u6389\u5c31\u4f1a\u6309\u7167\u6839\u76ee\u5f55\u5bfc\u822a<br \/> relativeTo: this.ActivatedRoute,<br \/> \/\/ \u8bbe\u7f6e\u67e5\u8be2\u53c2\u6570<br \/> queryParams: {<br \/> page: 1<br \/> },<br \/> \/\/ \u53ef\u4ee5\u5408\u5e76\u4e0a\u9762\u7684\u53c2\u6570\u548c\u539f\u672c url \u4e0a\u7684\u53c2\u6570\uff0c\u4e5f\u53ef\u4ee5\u5b8c\u5168\u66ff\u6362\u4e3a\u4e0a\u9762\u7684\u53c2\u6570<br \/> queryParamsHandling: &#8216;merge&#8217;,<br \/> \/\/ \u53ef\u4ee5\u8bbe\u7f6e\u951a\u70b9<br \/> fragment: &#8216;header&#8217;,<br \/>})<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037609\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lin07hui <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \/a\/1 \u548c \/b\/1 \u7684 name \u4e0d\u80fd\u76f8\u540c<br \/>{ path: &#8216;\/a\/1&#8217;, name: &#8216;a1&#8217;, &#8230; }<br \/>{ path: &#8216;\/b\/1&#8217;, name: &#8216;b1&#8217;, &#8230; }<br \/>$router.push(name : &#8216;a1&#8217;)<br \/>$router.push(name : &#8216;b1&#8217;)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037610\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rodrick <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1. name \u4e0d\u8981\u4e00\u6837\uff0c2. \u5199\u5168\u8def\u5f84 \/a\/1 or \/b\/1                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037611\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : muunala10221 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u597d\u7684\u8c22\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5037612\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : muunala10221 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @wunonglin \u8c22\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e2a\u524d\u7aef vueRouter \u95ee&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/312173"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312173"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/312173\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312173"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}