{"id":339912,"date":"2021-02-05T08:45:20","date_gmt":"2021-02-05T00:45:20","guid":{"rendered":"http:\/\/4563.org\/?p=339912"},"modified":"2021-02-05T08:45:20","modified_gmt":"2021-02-05T00:45:20","slug":"%e4%bb%98%e8%b4%b9%e8%af%b7%e6%95%99%e8%a7%a3%e5%86%b3-vue-router-%e9%97%ae%e9%a2%98%ef%bc%8c%e5%90%8e%e5%8f%b0%e6%a1%86%e6%9e%b6-vue-antd-admin","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=339912","title":{"rendered":"\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Joseph0717 <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u95ee\u9898\uff1a\u52a8\u6001\u6dfb\u52a0\u7684\u8def\u7531\u9875\u9762\u5237\u65b0\u540e 404 \u5982\u56fe\uff1a<img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/02\/20210218_602e8c8a30590.png\" alt=\"\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin\" \/><\/p>\n<p>\u6211\u7684\u64cd\u4f5c\uff1a 1,router\/config.js \u914d\u7f6e\u4e86\u9759\u6001\u7684\u51e0\u4e2a\u57fa\u7840\u8def\u7531 <img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/02\/20210218_602e8c8a40c41.png\" alt=\"\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin\" \/><\/p>\n<p>2\uff0c\u7528\u6237\u767b\u5f55\u6210\u529f\u52a8\u6001\u6dfb\u52a0\u8def\u7531\u548c\u83dc\u5355 <img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/02\/20210218_602e8c8a4f23d.png\" alt=\"\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin\" \/> <img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/02\/20210218_602e8c8a5ef40.png\" alt=\"\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin\" \/><\/p>\n<p>3\uff0c\u8def\u7531\u5b88\u536b\uff0c\u5237\u65b0\u9875\u9762\u518d\u6b21\u83b7\u53d6\u7528\u6237\u8def\u7531\u548c\u83dc\u5355 <img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/02\/20210218_602e8c8d65e05.png\" alt=\"\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin\" \/> <img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/02\/20210218_602e8c8f1be12.png\" alt=\"\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router \u95ee\u9898\uff0c\u540e\u53f0\u6846\u67b6 Vue Antd Admin\" \/><\/p>\n<p>4\uff0c\u4e00\u987f\u64cd\u4f5c\uff0c\u95ee\u9898\u8fd8\u662f 404<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>17<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5249373\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Joseph0717 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6551\u6551\u5b69\u5b50\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249374\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xm726 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a 404 \u653e\u5230\u6700\u540e\u53bb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249375\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ni9ht <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5148\u770b\u4e0b\u9875\u9762\u5237\u65b0\u540e\u6709\u6ca1\u6709\u8d70\u4f60\u7684 else \u91cc\u9762\u53bb\u8bf7\u6c42\u83b7\u53d6\u6570\u636e\uff0c\u5982\u679c\u6709\u8bf7\u6c42\u83b7\u53d6\u6570\u636e\u5c31\u770b\u770b\u8def\u7531\u6709\u6ca1\u6709\u6dfb\u52a0\u8fdb\u53bb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249376\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : InternetExplorer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a 404 \u7684\u8def\u7531\u5148\u62ff\u6389\u5462\uff1f<br \/>\u4f60\u8fd9 const\/let\/var \u4e71\u7528\uff0c\u770b\u7684\u6025\u6b7b\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249377\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : freakJacker <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a 404 \u653e\u5230\u6700\u540e\u5373\u53ef                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249378\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ni9ht <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u6ce8\u610f\u770b\u4f60 404 \u7684\u5199\u6cd5\uff0c\u53ef\u4ee5\u8bd5\u8bd5\u4e0a\u9762\u8bf4\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249379\" 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>                                                             \u6253\u5370\u4e00\u4e0b\u94a9\u5b50\u7684\u5165\u53c2\u4e2d\u7684 to\uff0c\u770b\u4e00\u4e0b to.redirectedFrom \u6216 to.path\uff0c\u53ef\u80fd\u6709\u60ca\u559c\u3002\u6211\u5370\u8c61\u4e2d\uff0c\u6309 f5 \u5237\u65b0\uff0c\u53ef\u80fd\u5df2\u7ecf\u88ab\u91cd\u5b9a\u5411\u5230 404 \u9875\u9762\u4e86\uff0c\u90a3\u5c31\u5f97 next({ path: to.redirectedFrom || to.path })\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249380\" 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>                                                             \u5148\u770b\u4e0b\u5237\u65b0\u540e\u7684 routers \u662f\u5565\uff0c\u5b98\u65b9\u6211\u8bb0\u5f97\u597d\u50cf\u8bf4\u4e0d\u63a8\u8350 this.$router.options.routes \u76f4\u63a5\u6539\uff0c\u4e0d\u786e\u5b9a\u8fd9\u6837\u4f1a\u4e0d\u4f1a\u6709\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249381\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Joseph0717 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xm726 404 \u653e\u5230\u6700\u540e\u8bd5\u8fc7\u4e86<br \/>@ni9ht \u6570\u636e\u53ef\u4ee5\u83b7\u53d6\u5230\uff0c404 \u9875\u9762\u6253\u5370\u8def\u7531\u90fd\u6709<br \/>@InternetExplorer 404 \u62ff\u6389\u62a5\u9519<br \/>@OHyn to.path \u662f\u6709\u7684<br \/>\u8c22\u8c22\u5404\u4f4d\uff0c\u6211\u7ee7\u7eed\u7814\u7a76\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249382\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Joseph0717 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @rodrick \u5237\u65b0\u540e 404 \u9875\u6253\u5370 router \u662f\u5b88\u536b\u91cc\u83b7\u53d6\u5230\u7684\u8def\u7531                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249383\" 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>                                                             @Joseph0717 \u5728 404 \u9875\u9762\u6253\u5370\u8def\u7531\uff0c\u8def\u7531\u90fd\u6709\u7684\u8bdd\uff0c\u7740\u91cd\u6392\u67e5\u79bb\u5f00\u94a9\u5b50\u65f6\u76ee\u6807\u9875\u9762\u7684\u8def\u5f84\uff0c\u4f60\u5f00 devtool \u770b\u4e00\u4e0b\u9875\u9762\u8df3\u8f6c\u7684\u8bb0\u5f55\uff0c\u6709\u8ff9\u53ef\u5faa\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249384\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chenluo0429 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u52a8\u6001\u8def\u7531\u6dfb\u52a0\u5230\u4e86\u6700\u540e\uff0c\u8def\u5f84\u88ab 404 \u7684*\u4f18\u5148\u5339\u914d\u4e86\uff1f\u6211\u8bb0\u5f97 addRoutes \u86ee\u591a\u5751\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249385\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : karott7 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             404 \u8def\u7531\u653e\u6700\u540e\u9762\uff0c\u6dfb\u52a0\u8def\u7531\u7528 addRoutes \u65b9\u6cd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249386\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lzhcscs <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e4b\u524d\u6709\u78b0\u5230\u8fc7\uff0c404 \u9875\u9762\u7528 addRouter \u518d\u6dfb\u52a0\u4e00\u6b21<br \/> router.addRoutes([{ path: &#8216;*&#8217;,name: &#8216;error_404&#8217;,component: err404 }])                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249387\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : serene11c <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             404 \u653e\u5728\u52a8\u6001\u6dfb\u52a0\u7684\u8def\u7531\u7684\u6700\u540e\uff0c\u9759\u6001\u7684\u4e0d\u7528\u653e<br \/>https:\/\/github.com\/vuejs\/vue-router\/issues\/1176                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249388\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : akcode <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8def\u7531\u53c8\u4e0d\u4f1a\u7ecf\u5e38\u53d8\uff0c\u8fd8\u4e0d\u5982\u5168\u90e8\u5199\u6210\u9759\u6001\u7684\uff0c\u505a\u8def\u7531\u6743\u9650\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5249389\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Unitent <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/blog.csdn.net\/Jack7757\/article\/details\/110315475 \u770b\u4e86\u8fd8\u4e0d\u61c2\u8bb0\u5f97\u52a0\u6211\u5fae\u4fe1 Unitent_                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4ed8\u8d39\u8bf7\u6559\u89e3\u51b3 vue-router&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\/339912"}],"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=339912"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/339912\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339912"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}