{"id":382,"date":"2024-10-24T10:39:03","date_gmt":"2024-10-24T02:39:03","guid":{"rendered":"https:\/\/eve2333.top\/?p=382"},"modified":"2024-10-24T10:39:03","modified_gmt":"2024-10-24T02:39:03","slug":"vue-part-11","status":"publish","type":"post","link":"https:\/\/eve2333.top\/?p=382","title":{"rendered":"Vue part-11"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">vuex\u7684\u6a21\u5757\u5316\u4e0enamespace<\/h1>\n\n\n\n<p><a href=\"https:\/\/www.bilibili.com\/video\/BV1Zy4y1K7SH\/?p=115&amp;spm_id_from=pageDriver&amp;vd_source=b31958e33027799323b8b7d77ae181d4\" target=\"_blank\"  rel=\"nofollow\" >115_\u5c1a\u7845\u8c37Vue\u6280\u672f_vuex\u6a21\u5757\u5316+namespace_1_\u54d4\u54e9\u54d4\u54e9_bilibili<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.bilibili.com\/video\/BV1Zy4y1K7SH\/?p=116&amp;spm_id_from=pageDriver&amp;vd_source=b31958e33027799323b8b7d77ae181d4\" target=\"_blank\"  rel=\"nofollow\" >116_\u5c1a\u7845\u8c37Vue\u6280\u672f_vuex\u6a21\u5757\u5316+namespace_2_\u54d4\u54e9\u54d4\u54e9_bilibili<\/a><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">vue-router\u8def\u7531<\/h1>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1058\" height=\"682\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736288-cc27c644bc3845b89a5f2e112f95a123.png\" alt=\"\" class=\"wp-image-383\" style=\"width:557px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736288-cc27c644bc3845b89a5f2e112f95a123.png 1058w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736288-cc27c644bc3845b89a5f2e112f95a123-300x193.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736288-cc27c644bc3845b89a5f2e112f95a123-1024x660.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736288-cc27c644bc3845b89a5f2e112f95a123-768x495.png 768w\" sizes=\"auto, (max-width: 1058px) 100vw, 1058px\" \/><\/figure>\n\n\n\n<p>\u5f88\u5e38\u89c1\u7684\u5f88\u91cd\u8981\u7684\u5e94\u7528\uff1aAjax\u8bf7\u6c42\uff0c\u5c06\u54cd\u5e94\u7684\u6570\u636e\u66ff\u6362\u6389\u539f\u5148\u7684\u4ee3\u7801\u4ece\u800c\u5b9e\u73b0\u4e0d\u8df3\u8f6c\u9875\u9762\u7684\u60c5\u51b5\u4e0b\u5b9e\u73b0\u5c40\u90e8\u5237\u65b0<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736309-6220899b7c79425eb11fba4eed18d96b-1024x640.png\" alt=\"\" class=\"wp-image-384\" style=\"width:557px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736309-6220899b7c79425eb11fba4eed18d96b-1024x640.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736309-6220899b7c79425eb11fba4eed18d96b-300x187.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736309-6220899b7c79425eb11fba4eed18d96b-768x480.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736309-6220899b7c79425eb11fba4eed18d96b.png 1084w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>1.\u4ec0\u4e48\u662f\u8def\u7531\uff1f<\/p>\n\n\n\n<p>1.\u4e00\u4e2a\u8def\u7531\u5c31\u662f\u4e00\u7ec4\u6620\u5c04\u5173\u7cfb\uff08key\u2014value\uff09<br>2. key \u4e3a\u8def\u5f84\uff0cvalue \u53ef\u80fd\u662ffunction \u6216 component<\/p>\n\n\n\n<p>2.\u8def\u7531\u5206\u7c7b<br>1.\u540e\u7aef\u8def\u7531\uff1a<br>1\uff09\u7406\u89e3\uff1avalue \u662ffunction\uff0c\u7528\u4e8e\u5904\u7406\u5ba2\u6237\u7aef\u63d0\u4ea4\u7684\u8bf7\u6c42\u3002<br>2\uff09\u5de5\u4f5c\u8fc7\u7a0b\uff1a\u670d\u52a1\u5668\u63a5\u6536\u5230\u4e00\u4e2a\u8bf7\u6c42\u65f6\uff0c\u6839\u636e\u8bf7\u6c42\u8def\u5f84\u627e\u5230\u5339\u914d\u7684\u51fd\u6570\u6765\u5904<br>\u7406\u8bf7\u6c42\uff0c\u8fd4\u56de\u54cd\u5e94\u6570\u636e\u3002&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.\u524d\u7aef\u8def\u7531\uff1a<br>1)\u7406\u89e3\uff1avalue \u662fcomponent,\u7528\u4e8e\u5c55\u793a\u9875\u9762\u5185\u5bb9\u3002<br>2\uff09\u5de5\u4f5c\u8fc7\u7a0b\uff1a\u5f53\u6d4f\u89c8\u5668\u7684\u8def\u5f84\u6539\u53d8\u65f6\uff0c\u5bf9\u5e94\u7684\u7ec4\u4ef6\u5c31\u4f1a\u663e\u793a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u57fa\u672c\u8def\u7531<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>npm i vue-rounter@3<\/code><\/pre>\n\n\n\n<p>&nbsp;\u548c\u539f\u6765\u90a3\u6837\u76f8\u540c\uff0c\u90fd\u662fvue3\u66f4\u65b0\u7248\u672c\u4f1a\u62a5\u9519<\/p>\n\n\n\n<p>&nbsp;index.js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u8be5\u6587\u4ef6\u4e13\u95e8\u7528\u4e8e\u521b\u5efa\u6574\u4e2a\u5e94\u7528\u7684\u8def\u7531\u5668\n\nimport VueRouter from \"vue-router\";\nimport About from \"@\/components\/About\";\nimport Home from '@\/components\/Home';\n\n\/\/\u521b\u5efa\u5e76\u9ed8\u8ba4\u66b4\u9732\u4e00\u4e2a\u8def\u7531\u5668\nexport default new VueRouter({\n   routes:&#91;\n       {\n           path:'\/about',\n           component: About\n       },\n       {\n           path:'\/home',\n           component: Home\n       }\n   ]\n});<\/code><\/pre>\n\n\n\n<p><strong>App.vue<\/strong><\/p>\n\n\n\n<p>router-link\u7684\u7279\u6b8a\u6807\u7b7e\uff0c\u5b9e\u73b0\u8def\u7531 \u5207\u6362 \u200b<img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"211\" class=\"wp-image-385\" style=\"width: 600px;\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736380-7b069c24e5a94fe8bf0583b042026c94.png\" alt=\"\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736380-7b069c24e5a94fe8bf0583b042026c94.png 988w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736380-7b069c24e5a94fe8bf0583b042026c94-300x105.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736380-7b069c24e5a94fe8bf0583b042026c94-768x270.png 768w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n  &lt;div&gt;\n    &lt;div class=\"row\"&gt;\n      &lt;div class=\"col-xs-offset-2 col-xs-8\"&gt;\n        &lt;div class=\"page-header\"&gt;&lt;h2&gt;Vue Router Demo&lt;\/h2&gt;&lt;\/div&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n    &lt;div class=\"row\"&gt;\n      &lt;div class=\"col-xs-2 col-xs-offset-2\"&gt;\n        &lt;div class=\"list-group\"&gt;\n          &lt;!--\u539f\u59cb\u4f7f\u7528a\u6807\u7b7e\u8df3\u8f6c\u591a\u4e2a\u9875\u9762,\u591a\u9875\u9762\u5e94\u7528--&gt;\n&lt;!--          &lt;a class=\"list-group-item active\" href=\".\/about.html\"&gt;About&lt;\/a&gt;--&gt;\n&lt;!--          &lt;a class=\"list-group-item\" href=\".\/home.html\"&gt;Home&lt;\/a&gt;--&gt;\n          &lt;!--vue\u4e2d\u501f\u52a9router=link\u6807\u7b7e\u5b9e\u73b0\u8def\u7531\u7684\u5207\u6362--&gt;\n          &lt;router-link class=\"list-group-item\" active-class=\"active\" to=\"\/about\"&gt;About&lt;\/router-link&gt;\n          &lt;router-link class=\"list-group-item\" active-class=\"active\" to=\"\/home\"&gt;Home&lt;\/router-link&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n      &lt;div class=\"col-xs-6\"&gt;\n        &lt;div class=\"panel\"&gt;\n          &lt;div class=\"panel-body\"&gt;\n            &lt;!--router-view\u786e\u5b9a\u89c6\u56fe\u7684\u4f4d\u7f6e--&gt;\n            &lt;router-view&gt;\n            &lt;\/router-view&gt;\n          &lt;\/div&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nexport default {\n  name: \"App\",\n}\n&lt;\/script&gt;\n&lt;style lang=\"css\" scoped&gt;\n\n&lt;\/style&gt;<\/code><\/pre>\n\n\n\n<p>main.js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u5f15\u5165Vue\nimport Vue from \"vue\";\n\/\/\u5f15\u5165App\nimport App from '.\/App';\n\/\/\u5f15\u5165vue-router\nimport VueRouter from \"vue-router\";\nimport router from '.\/router';\n\n\/\/\u5173\u95edVue\u7684\u751f\u4ea7\u63d0\u793a\nVue.config.productionTip = false;\n\n\/\/\u5e94\u7528vue-router\u63d2\u4ef6\nVue.use(VueRouter);\n\nnew Vue({\n    el: '#app',\n    render: h =&gt; h(App),\n    router\n});<\/code><\/pre>\n\n\n\n<p>About.vue<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n  &lt;h2&gt;\u6211\u662fAbout\u7684\u5185\u5bb9&lt;\/h2&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nexport default {\n  name: \"About\"\n}\n&lt;\/script&gt;\n\n&lt;style scoped&gt;\n\n&lt;\/style&gt;\n<\/code><\/pre>\n\n\n\n<p>Home.vue\u4e24\u4e2a\u5f88\u76f8\u4f3c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;template&gt;\n  &lt;h2&gt;\u6211\u662fHome\u7684\u5185\u5bb9&lt;\/h2&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nexport default {\n  name: \"Home\"\n}\n&lt;\/script&gt;\n\n&lt;style scoped&gt;\n&lt;\/style&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5d4c\u5957\uff08\u591a\u7ea7\uff09\u8def\u7531<\/h3>\n\n\n\n<p>shift + Tab \u662f\u5f80\u524d\u7f29\u8fdb Tab\u662f\u5f80\u540e\u7f29\u8fdb<\/p>\n\n\n\n<p>\u8def\u7531\u8def\u5f84\u7684\u53d8\u5316<br> \u200b<img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"645\" class=\"wp-image-386\" style=\"width: 650px;\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736607-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102249.png\" alt=\"\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736607-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102249.png 789w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736607-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102249-300x298.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736607-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102249-150x150.png 150w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736607-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102249-768x762.png 768w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u00a0\u8def\u7531\u4f20\u53c2<\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"731\" height=\"614\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736651-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102256.png\" alt=\"\" class=\"wp-image-387\" style=\"width:493px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736651-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102256.png 731w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736651-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102256-300x252.png 300w\" sizes=\"auto, (max-width: 731px) 100vw, 731px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1064\" height=\"636\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736666-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102305.png\" alt=\"\" class=\"wp-image-388\" style=\"width:770px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736666-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102305.png 1064w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736666-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102305-300x179.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736666-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102305-1024x612.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736666-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102305-768x459.png 768w\" sizes=\"auto, (max-width: 1064px) 100vw, 1064px\" \/><\/figure>\n<\/div>\n\n\n<h4 class=\"wp-block-heading\">\u547d\u540d\u8def\u7531<\/h4>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"947\" height=\"685\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736912-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102509.png\" alt=\"\" class=\"wp-image-389\" style=\"width:682px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736912-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102509.png 947w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736912-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102509-300x217.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736912-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102509-768x556.png 768w\" sizes=\"auto, (max-width: 947px) 100vw, 947px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"888\" height=\"535\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736923-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102517.png\" alt=\"\" class=\"wp-image-390\" style=\"width:672px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736923-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102517.png 888w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736923-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102517-300x181.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736923-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102517-768x463.png 768w\" sizes=\"auto, (max-width: 888px) 100vw, 888px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1025\" height=\"659\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736951-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102533.png\" alt=\"\" class=\"wp-image-391\" style=\"width:706px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736951-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102533.png 1025w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736951-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102533-300x193.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736951-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102533-768x494.png 768w\" sizes=\"auto, (max-width: 1025px) 100vw, 1025px\" \/><\/figure>\n<\/div>\n\n\n<h4 class=\"wp-block-heading\">params\u53c2\u6570<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1050\" height=\"493\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736996-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102938.png\" alt=\"\" class=\"wp-image-392\" style=\"width:737px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736996-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102938.png 1050w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736996-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102938-300x141.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736996-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102938-1024x481.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729736996-\u5c4f\u5e55\u622a\u56fe-2024-10-24-102938-768x361.png 768w\" sizes=\"auto, (max-width: 1050px) 100vw, 1050px\" \/><\/figure>\n\n\n\n<p>\u4e24\u79cd\u5199\u6cd5<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a><\/a>props\u5199\u6cd5<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code> children:&#91;\n{\n    name:'xiangqing',\n    path:'detail',\n    component:Detail,\n\n    \/\/props\u7684\u7b2c\u4e00\u79cd\u5199\u6cd5\uff0c\u503c\u4e3a\u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u4e2d\u7684\u6240\u6709key-value\u90fd\u4f1a\u4ee5props\u7684\u5f62\u5f0f\u4f20\u7ed9Detail\u7ec4\u4ef6\u3002\n    \/\/ props:{a:1,b:'hello'}\n   \n    \/\/props\u7684\u7b2c\u4e8c\u79cd\u5199\u6cd5\uff0c\u503c\u4e3a\u5e03\u5c14\u503c\uff0c\u82e5\u5e03\u5c14\u503c\u4e3a\u771f\uff0c\u5c31\u4f1a\u628a\u8be5\u8def\u7531\u7ec4\u4ef6\u6536\u5230\u7684\u6240\u6709params\u53c2\u6570\uff0c\u4ee5props\u7684\u5f62\u5f0f\u4f20\u7ed9Detail\u7ec4\n    \/\/ props:true\n\n    \/\/props\u7684\u7b2c\u4e09\u79cd\u5199\u6cd5\uff0c\u503c\u4e3a\u51fd\u6570I\n    props($route){\n        return{\n            id:$route.query.id,\n            title:$route.query.title\n        }\n    }    <\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"988\" height=\"607\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737069-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103053.png\" alt=\"\" class=\"wp-image-393\" style=\"width:700px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737069-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103053.png 988w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737069-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103053-300x184.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737069-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103053-768x472.png 768w\" sizes=\"auto, (max-width: 988px) 100vw, 988px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">router-link&nbsp;<\/h3>\n\n\n\n<p>P125\u4e3b\u8981\u662f\u4ec0\u4e48\uff1f<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7f16\u7a0b\u5f0f\u8def\u7531\u5bfc\u822a<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">\u7f13\u5b58\u8def\u7531\u7ec4\u4ef6<\/h3>\n\n\n\n<p>\u5982\u4f55\u5728\u7ec4\u4ef6\u8f93\u5165\u540e\uff0c\u5207\u6362\u4e86\u4e0d\u628a\u7ec4\u4ef6\u9500\u6bc1\uff1f<\/p>\n\n\n\n<p>\u5982\u679ckeep-alive \u4ec0\u4e48\u90fd\u4e0d\u5199\uff0c\u5c31\u4ee3\u8868\u6b64\u5904\u5c55\u793a\u7684\u6240\u6709\u7ec4\u4ef6\u90fd\u4fdd\u6301\u6d3b\u8dc3\uff0c\u56e0\u6b64include=\"News\"\u6765\u9650\u5b9a\u8303\u56f4<\/p>\n\n\n\n<p>1.\u4f5c\u7528\uff1a\u8ba9\u4e0d\u5c55\u793a\u7684\u8def\u7531\u7ec4\u4ef6\u4fdd\u6301\u6302\u8f7d\uff0c\u4e0d\u88ab\u9500\u6bc1\u3002<br>2. \u5177\u4f53\u7f16\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;keep-alive include=\"News\"&gt;\n    &lt;router-view&gt;&lt;\/router-view&gt;\n&lt;\/keep-alive&gt;<\/code><\/pre>\n\n\n\n<p>&nbsp;\u591a\u4e2a\u7f13\u5b58<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> &lt;keep-alive :include=\"&#91;'News','Messages']\"&gt;\n    &lt;router-view&gt;&lt;\/router-view&gt;\n &lt;\/keep-alive&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e24\u4e2a\u65b0\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50<\/h3>\n\n\n\n<p>\u63d0\u793a: \u8fd92\u4e2a\u94a9\u5b50\u51fd\u6570\u9700\u8981\u914d\u5408 keep-alive \u6807\u7b7e\u4f7f\u7528<\/p>\n\n\n\n<p><a href=\"https:\/\/www.bilibili.com\/video\/BV1Zy4y1K7SH\/?p=128&amp;spm_id_from=pageDriver&amp;vd_source=b31958e33027799323b8b7d77ae181d4\" target=\"_blank\"  rel=\"nofollow\" >128_\u5c1a\u7845\u8c37Vue\u6280\u672f_\u4e24\u4e2a\u65b0\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50_\u54d4\u54e9\u54d4\u54e9_bilibili<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8def\u7531\u5b88\u536b<\/h2>\n\n\n\n<p>\u4fdd\u62a4\u8def\u7531\u5b89\u5168\uff0c\u5224\u65ad\u662f\u4e0d\u662f\u7684\u6761\u4ef6\uff08\u6743\u9650\uff09\u624d\u80fd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5168\u5c40\u524d\u7f6e<\/h3>\n\n\n\n<p>\u524d\u7aef\u628a\u672c\u5730\u5b58\u50a8\u7684jwt\u7ed9\u5b89\u5168\u6846\u67b6\u8ba4\u8bc1\uff0c\u8fc7\u4e86\u7684\u8bdd\u7ed9\u4e00\u4e2a\u8fd4\u56de\u503c\uff0c\u6839\u636e\u8fd4\u56de\u503c\u6765\u8df3\u8f6c\u8def\u7531\u5427\uff0c\u7f16\u7a0b\u5f0f\u8def\u7531 \u200b<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"907\" height=\"1002\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737176-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103239.png\" alt=\"\" class=\"wp-image-394\" style=\"width:545px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737176-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103239.png 907w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737176-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103239-272x300.png 272w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737176-\u5c4f\u5e55\u622a\u56fe-2024-10-24-103239-768x848.png 768w\" sizes=\"auto, (max-width: 907px) 100vw, 907px\" \/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">&nbsp;\u5168\u5c40\u540e\u7f6e<\/h3>\n\n\n\n<p>\u56e0\u4e3a\u4f60\u8fd8\u662f\u5728\u8ba9\u670d\u52a1\u5668\u63a7\u5236\u9875\u9762\u7684\u8df3\u8f6c\u3002\u5b8c\u5168\u8fdd\u80cc\u4e86\u524d\u540e\u7aef\u5206\u79bb\u7684\u521d\u8877\u3002\u8fd9\u4e2a\u5df2\u7ecf\u8d85\u51fa\u4e86\u540e\u7aef\u7684\u5de5\u4f5c\u8303\u56f4\uff0c\u540e\u7aef\u53ea\u4fdd\u8bc1\u6570\u636e\u5b89\u5168\uff1a\u5373\u8ba9\u7279\u5b9a\u7684\u4eba\u62ff\u5230\u7279\u5b9a\u7684\u6570\u636e\u3002\u800c\u9875\u9762\u5b89\u5168\uff1a\u5373\u8ba9\u7279\u5b9a\u7684\u4eba\u8bbf\u95ee\u7279\u5b9a\u7684\u9875\u9762\u3002\u662f\u524d\u7aef\u7684\u5de5\u4f5c\u3002<\/p>\n\n\n\n<p>&nbsp;P130<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u72ec\u4eab\u8def\u7531\u5b88\u536b<\/h3>\n\n\n\n<p>P131<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7ec4\u4ef6\u5185\u8def\u7531\u5b88\u536b<\/h3>\n\n\n\n<p>P132<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">hash\u548chistory<\/h3>\n\n\n\n<p>hsah\u662f\u4e0d\u4f1a\u53d1\u7ed9\u670d\u52a1\u5668\u7684\uff0c\u8fd8\u6709history\u6a21\u5f0f<\/p>\n\n\n\n<p>hash\u662f\u7531#\uff0c\u4f46\u662fhistory\u53ea\u8981\/\u5373\u53ef\uff0c\u4f46\u662f\u4ed6\u5728ie\u4e2d\u96be\u4ee5\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run build<\/code><\/pre>\n\n\n\n<p>\u8fdb\u884c\u6253\u5305\u51fa\u6765dist\uff0c\uff08webpack\uff09\u7136\u540enode express\u90e8\u7f72<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm init\n\u7136\u968f\u4fbf\u8d77\u4e2a\u540d\u5b57\natguigu_test_server\n\nnpm i express\n\n\u5199\u4ee3\u7801server.js\ncli\nnode server<\/code><\/pre>\n\n\n\n<p>server.js<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const express = require('express')\n\nconst app = express()\napp.use(express.static(__dirname+'\/static'))\n\napp.get('\/person',(req,res)=&gt;{\n    res.send({\n        name:'tom',\n        age:18\n    })\n})\n\napp.listen(5005,(err)=&gt;{\n    if(!err) console.log('\u670d\u52a1\u5668\u542f\u52a8\u6210\u529f!')\n})<\/code><\/pre>\n\n\n\n<p>\u53d1\u73b0history\u6a21\u5f0f\u66f4\u9ebb\u70e6\uff0c\u4e0d\u5982hash\uff0c\u56e0\u4e3a\u5237\u65b0\u5c31cannot GET<\/p>\n\n\n\n<p>\u5982\u4f55\u89e3\u51b3\uff1f\u4ec0\u4e48java\u5e93\u963f\uff0c\u540e\u7aef\u7684\u67d0\u4e9b\u914d\u5408\uff0cnginx\u963f<\/p>\n\n\n\n<p>\u4f46\u662f\u6b64\u5e93\u53ef\u4ee5\u89e3\u51b3\u90e8\u5206\u95ee\u9898 \u200b<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1255\" height=\"732\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737228-88759c328f13424d855ac87a7893be00.png\" alt=\"\" class=\"wp-image-395\" style=\"width:645px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737228-88759c328f13424d855ac87a7893be00.png 1255w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737228-88759c328f13424d855ac87a7893be00-300x175.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737228-88759c328f13424d855ac87a7893be00-1024x597.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737228-88759c328f13424d855ac87a7893be00-768x448.png 768w\" sizes=\"auto, (max-width: 1255px) 100vw, 1255px\" \/><\/figure>\n<\/div>\n\n\n<h1 class=\"wp-block-heading\">&nbsp;VUE UI\u7ec4\u4ef6\u5e93<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Vue UI \u7ec4\u4ef6\u5e93<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><a><\/a>Vue\u9002\u914d\u7ec4\u4ef6\u5e93\u63a8\u8350<\/h3>\n\n\n\n<p><strong>\u7ec4\u4ef6\u5e93\u4e4b\u6240\u4ee5\u53eb\u7ec4\u4ef6\u5e93\uff0c\u4e00\u5b9a\u662f\u4e3a\u4e86\u9002\u5e94\u7ec4\u4ef6\u5316\u5f00\u53d1\u7528\u7684\u7ec4\u4ef6\u5e93\u3002\u6240\u4ee5Vue\u6709Vue\u9002\u914d\u7684\u7ec4\u4ef6\u5e93\uff0cReact\u6709React\u9002\u914d\u7684\u7ec4\u4ef6\u5e93\u3002<\/strong><\/p>\n\n\n\n<p><strong>\u7531\u4e8e\u662f\u7ec4\u4ef6\u561b\uff0c\u6240\u4ee5\u5168\u90fd\u9700\u8981\u7528\u5230\uff1aVue.use(XXX)<\/strong><\/p>\n\n\n\n<p><strong>\u4e0b\u9762\u4ecb\u7ecd\u7684\u5168\u90fd\u662fVue\u9002\u914d\uff1a<\/strong><\/p>\n\n\n\n<p>\u79fb\u52a8\u7aef\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Vant https:\/\/youzan.github.io\/vant<\/li>\n\n\n\n<li>Cube UI https:\/\/didi.github.io\/cube-ui<\/li>\n\n\n\n<li>Mint UI https:\/\/mint-ui.github.io<\/li>\n\n\n\n<li>NutUI \u4eac\u4e1c\u79fb\u52a8\u7aefVue\u7ec4\u4ef6\u5e93\uff01<\/li>\n<\/ul>\n\n\n\n<p>PC\u7aef\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Element UI https:\/\/element.eleme.cn<\/li>\n\n\n\n<li>IView UI https:\/\/www.iviewui.com<\/li>\n<\/ul>\n\n\n\n<p><strong>\u7279\u522b\u63a8\u8350\uff1a\u9489\u8019\uff08tinper-bee\uff09<\/strong><\/p>\n\n\n\n<p>\u5728\u6211\u7684React\u7b14\u8bb0\u4e2d\u8fd8\u8981\u518d\u6b21\u63a8\u8350\u4e00\u6b21\uff01<\/p>\n\n\n\n<p>http:\/\/bee.tinper.org\/design-new\/<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><code>tinper-bee<\/code>&nbsp;\u662f\u4e00\u5957\u57fa\u4e8e&nbsp;<code>React.js<\/code>&nbsp;\u7684\u5f00\u6e90\u7ec4\u4ef6\u5e93\uff0c\u5b83\u4ece\u4e30\u5bcc\u7684\u4f01\u4e1a\u7ea7\u4e2d\u540e\u53f0\u5e94\u7528\u573a\u666f\u4e2d\u5b9e\u6218\u6c89\u6dc0\u800c\u6765\uff0c\u4e3a\u590d\u6742\u5e94\u7528\u7684\u5feb\u901f\u5f00\u53d1\u63d0\u4f9b\u4e00\u81f4\u6027&nbsp;<code>UI<\/code>&nbsp;\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><a><\/a>\u7ec4\u4ef6\u7684\u5168\u90e8\u5f15\u5165\u548c\u6309\u9700\u5f15\u5165<\/h3>\n\n\n\n<p>\u4ee5&nbsp;Element&nbsp;UI\u4e3a\u4f8b\uff1a\u5982\u679c\u4f60\u5168\u90e8\u5f15\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u5f15\u5165ElementUI\u7ec4\u4ef6\u5e93\nimport ElementUI from 'element-ui';\n\/\/\u5f15\u5165ElementUI\u5168\u90e8\u6837\u5f0f\nimport 'element-ui\/lib\/theme-chalk\/index.css';\n\/\/\u5e94\u7528ElementUI\nVue.use(ElementUI);<\/code><\/pre>\n\n\n\n<p><strong>\u4f1a\u53d1\u73b0\u81c3\u80bf\u65e0\u6bd4\uff1a<\/strong> \u200b<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1255\" height=\"732\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00.png\" alt=\"\" class=\"wp-image-396\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00.png 1255w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00-300x175.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00-1024x597.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00-768x448.png 768w\" sizes=\"auto, (max-width: 1255px) 100vw, 1255px\" \/><\/figure>\n\n\n\n<p><strong>\u6240\u4ee5\u6211\u4eec\u9700\u8981\u6309\u9700\u5f15\u5165<\/strong>\uff1a<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"467\" class=\"wp-image-396\" style=\"width: 800px;\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00.png\" alt=\"\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00.png 1255w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00-300x175.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00-1024x597.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2024\/10\/1729737445-88759c328f13424d855ac87a7893be00-768x448.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><img loading=\"lazy\" decoding=\"async\" height=\"15\" width=\"15\" src=\"blob:https:\/\/eve2333.top\/8a469bae-fdc8-481b-9301-12dde7cd5b89\"><\/p>\n\n\n\n<p>\u6837\u4f8bbabel.config.js\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>module.exports = {\n  presets: &#91;\n    '@vue\/cli-plugin-babel\/preset',\n\t\t&#91;\"@babel\/preset-env\", { \"modules\": false }],\n  ],\n\tplugins:&#91;\n    &#91;\n      \"component\",\n      {\n        \"libraryName\": \"element-ui\",\n        \"styleLibraryName\": \"theme-chalk\"\n      }\n    ]\n  ]\n}<\/code><\/pre>\n\n\n\n<p>main.js\u4e2d\u6309\u9700\u5f15\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import Vue from 'vue';\nimport { Button, Select } from 'element-ui';\nimport App from '.\/App.vue';\n\nVue.component(Button.name, Button);\nVue.component(Select.name, Select);\n\/* \u6216\u5199\u4e3a\n * Vue.use(Button)\n * Vue.use(Select)\n *\/\n\nnew Vue({\n  el: '#app',\n  render: h =&gt; h(App)\n});\n<\/code><\/pre>\n\n\n\n<p><strong>\u6309\u7167\u5b98\u7f51\u6307\u5f15\u505a\u5c31\u597d\u4e86<\/strong> \u200b<\/p>\n\n\n\n<p><strong>Vue3\u7684\u5c55\u671b<\/strong>\uff01<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>vuex\u7684\u6a21\u5757\u5316\u4e0enamespace 115_\u5c1a\u7845\u8c37Vue\u6280\u672f_vuex\u6a21\u5757\u5316+namespace_1_\u54d4\u54e9\u54d4\u54e9_bilibili &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[2],"tags":[12,11,10],"class_list":["post-382","post","type-post","status-publish","format-standard","hentry","category-2","tag-js","tag-vue","tag-10"],"_links":{"self":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=382"}],"version-history":[{"count":0,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions"}],"wp:attachment":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}