{"id":4049,"date":"2026-06-11T17:33:59","date_gmt":"2026-06-11T09:33:59","guid":{"rendered":"https:\/\/www.gaigaiming.com\/?p=4049"},"modified":"2026-06-11T17:33:59","modified_gmt":"2026-06-11T09:33:59","slug":"pinia-%e5%92%8cevantbus","status":"publish","type":"post","link":"https:\/\/www.gaigaiming.com\/index.php\/2026\/06\/11\/pinia-%e5%92%8cevantbus\/","title":{"rendered":"Pinia \u548cEvantBus"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728 Vue3 \u91cc\uff0c<strong>Pinia \u5e76\u4e0d\u662f\u4e3a\u4e86\u201c\u7236\u4f20\u5b50\u201d\u8fd9\u79cd\u7b80\u5355\u573a\u666f\u8bbe\u8ba1\u7684<\/strong>\u3002\u5b83\u7684\u6838\u5fc3\u804c\u8d23\u662f<strong>\u8de8\u5c42\u7ea7\u3001\u8de8\u7ec4\u4ef6\u5730\u5171\u4eab\u72b6\u6001<\/strong>\uff0c\u628a\u6240\u6709\u9700\u8981\u5171\u4eab\u7684\u6570\u636e\u90fd\u653e\u5728\u4e00\u4e2a\u4e2d\u592e\u201c\u4ed3\u5e93\u201d\u91cc\uff0c\u8ba9\u4efb\u4f55\u7ec4\u4ef6\u90fd\u80fd\u8bbf\u95ee\u548c\u4fee\u6539\uff0c\u4ece\u800c\u907f\u514d\u5728\u591a\u5c42\u7ec4\u4ef6\u4e2d\u201cprop drilling\u201d\uff08\u9010\u5c42\u4f20\u9012\uff09\u7684\u7e41\u7410\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"> \u7528\u4ee3\u7801\u7406\u89e3 Pinia\uff1a\u5c06\u6570\u636e\u653e\u8fdb\u201c\u4e2d\u592e\u4ed3\u5e93\u201d<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Pinia\u7684\u6838\u5fc3\u673a\u5236\u5c31\u662f\u628a\u6570\u636e\u653e\u8fdbStore\uff08\u4ed3\u5e93\uff09\uff0c\u7136\u540e\u5404\u4e2a\u7ec4\u4ef6\u5c31\u50cf\u987e\u5ba2\u4e00\u6837\uff0c\u76f4\u63a5\u4ece\u4ed3\u5e93\u91cc\u53d6\u7528\u81ea\u5df1\u9700\u8981\u7684\u6570\u636e\uff0c\u6216\u8005\u628a\u6570\u636e\u5b58\u8fdb\u53bb\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b2c\u4e00\u6b65\uff1a\u5b89\u88c5\u5e76\u521b\u5efa\u4e00\u4e2a Store<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u4f60\u9700\u8981\u6709\u4e00\u4e2a\u4e2d\u592e\u4ed3\u5e93\u6765\u5b58\u653e\u5168\u5c40\u6570\u636e\u3002\u8fd9\u901a\u5e38\u5728 <code>store<\/code> \u76ee\u5f55\u4e0b\u5b8c\u6210\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ store\/user.js\nimport { defineStore } from 'pinia'\n\nexport const useUserStore = defineStore('user', {\n  \/\/ \u5b58\u653e\u5168\u5c40\u6570\u636e\uff1a\u7528\u6237\u4fe1\u606f\n  state: () =&gt; ({\n    name: '\u5f20\u4e09',\n    avatar: '',\n    age: 30\n  }),\n  \/\/ \u5b58\u653e\u8ba1\u7b97\u5c5e\u6027\uff1a\u6bd4\u5982\u6839\u636e\u5e74\u9f84\u5224\u65ad\u662f\u5426\u6210\u5e74\n  getters: {\n    isAdult: (state) =&gt; state.age &gt;= 18\n  },\n  \/\/ \u5b58\u653e\u4fee\u6539\u6570\u636e\u7684\u65b9\u6cd5\n  actions: {\n    \/\/ \u4e00\u4e2a\u540c\u6b65\u7684\u66f4\u65b0\u65b9\u6cd5\n    updateName(newName) {\n      this.name = newName\n    },\n    \/\/ \u4e5f\u53ef\u4ee5\u6709\u5f02\u6b65\u64cd\u4f5c\uff0c\u6bd4\u5982\u4eceAPI\u83b7\u53d6\u7528\u6237\u6570\u636e\n    async fetchUser() {\n      \/\/ const res = await api.getUser()\n      \/\/ this.name = res.data.name\n    }\n  }\n})<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u7b2c\u4e8c\u6b65\uff1a\u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u8fd9\u4e2a Store<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u4efb\u4f55\u7ec4\u4ef6\u90fd\u80fd\u901a\u8fc7 <code>useUserStore()<\/code> \u8fd9\u4e2a\u201c\u94a9\u5b50\u201d\u6765\u8bbf\u95ee\u4ed3\u5e93\u91cc\u7684\u6570\u636e\u548c\u65b9\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- \u7ec4\u4ef6A.vue --&gt;\n&lt;template&gt;\n  &lt;div&gt;\n    &lt;!-- \u76f4\u63a5\u4f7f\u7528 state \u4e2d\u7684\u6570\u636e --&gt;\n    &lt;p&gt;\u7528\u6237\u540d\uff1a{{ userStore.name }}&lt;\/p&gt;\n    &lt;!-- \u4f7f\u7528 getters --&gt;\n    &lt;p&gt;\u662f\u5426\u6210\u5e74\uff1a{{ userStore.isAdult ? '\u662f' : '\u5426' }}&lt;\/p&gt;\n    &lt;!-- \u53ef\u4ee5\u7ed1\u5b9a\u5230\u8f93\u5165\u6846\uff0c\u8fdb\u884c\u53cc\u5411\u4fee\u6539 --&gt;\n    &lt;input v-model=\"userStore.name\" \/&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script setup&gt;\nimport { useUserStore } from '@\/store\/user'\n\n\/\/ \u83b7\u53d6 Store \u5b9e\u4f8b\nconst userStore = useUserStore()\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- \u7ec4\u4ef6B.vue --&gt;\n&lt;template&gt;\n  &lt;div&gt;\n    &lt;!-- \u8fd9\u91cc\u7684 name \u4f1a\u548c\u7ec4\u4ef6A\u4e2d\u7684 name \u4fdd\u6301\u540c\u6b65 --&gt;\n    &lt;p&gt;\u53e6\u4e00\u4e2a\u7ec4\u4ef6\u770b\u5230\u7684\u7528\u6237\u540d\uff1a{{ userStore.name }}&lt;\/p&gt;\n    &lt;!-- \u8c03\u7528 action \u6765\u4fee\u6539\u6570\u636e --&gt;\n    &lt;button @click=\"userStore.updateName('\u674e\u56db')\"&gt;\u4fee\u6539\u59d3\u540d&lt;\/button&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script setup&gt;\nimport { useUserStore } from '@\/store\/user'\n\nconst userStore = useUserStore()\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u7ec4\u4ef6A\u548c\u7ec4\u4ef6B\u901a\u8fc7Pinia\u91cc\u7684 <code>useUserStore<\/code> \u5171\u4eab\u4e86\u540c\u4e00\u4efd <code>name<\/code> \u6570\u636e\uff0c\u4efb\u610f\u4e00\u4e2a\u7ec4\u4ef6\u4fee\u6539\u5b83\uff0c\u53e6\u4e00\u4e2a\u7ec4\u4ef6\u90fd\u4f1a\u7acb\u523b\u770b\u5230\u53d8\u5316\uff0c\u5b8c\u7f8e\u5b9e\u73b0\u8de8\u7ec4\u4ef6\u901a\u4fe1\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2694\ufe0f \u7ec4\u4ef6\u95f4\u901a\u4fe1\u65b9\u5f0f\u5bf9\u6bd4<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Vue \u4e2d\uff0c\u5230\u5e95\u8be5\u7528 Pinia \u8fd8\u662f\u5176\u4ed6\u65b9\u5f0f\uff0c\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u539f\u5219\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">\u901a\u4fe1\u573a\u666f<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u63a8\u8350\u65b9\u6848<\/th><th class=\"has-text-align-left\" data-align=\"left\">\u9002\u7528\u573a\u666f<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u7b80\u5355\u7236\u5b50\u7ec4\u4ef6<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\"><code>props<\/code> \/ <code>emit<\/code><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u6570\u636e\u4ec5\u7531\u7236\u7ec4\u4ef6\u4f20\u7ed9\u5b50\u7ec4\u4ef6\uff0c\u6216\u5b50\u7ec4\u4ef6\u89e6\u53d1\u7236\u7ec4\u4ef6\u4e8b\u4ef6\u3002\u4f8b\u5982\u4e00\u4e2a\u6309\u94ae\u7ec4\u4ef6\u89e6\u53d1\u7236\u9875\u9762\u7684\u63d0\u4ea4\u4e8b\u4ef6\u3002<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u7237\u5b59\/\u6df1\u5c42\u7ec4\u4ef6<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\"><code>provide<\/code> \/ <code>inject<\/code><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u4e00\u4e2a\u7ec4\u4ef6\u4e3a\u5b83\u6240\u6709\u7684\u540e\u4ee3\u7ec4\u4ef6\u63d0\u4f9b\u4e00\u4e2a\u6570\u636e\u6e90\uff0c\u907f\u514d\u6570\u636e\u5728\u4e2d\u95f4\u5c42\u7ec4\u4ef6\u88ab\u5c42\u5c42\u4f20\u9012\u3002<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u5168\u5c40\/\u590d\u6742\u72b6\u6001<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\"><strong>Pinia<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u4efb\u4f55\u7ec4\u4ef6\u4e4b\u95f4\u9700\u8981\u5171\u4eab\u548c\u53d8\u66f4\u540c\u4e00\u4e2a\u6570\u636e<\/strong>\uff0c\u6216\u8005\u4f60\u7684\u5e94\u7528\u89c4\u6a21\u8f83\u5927\u3001\u7ec4\u4ef6\u5c42\u7ea7\u5f88\u6df1\u65f6\u3002\u4f8b\u5982\u524d\u9762\u63d0\u5230\u7684\u7528\u6237\u767b\u5f55\u4fe1\u606f\u3001\u6574\u4e2a\u8d2d\u7269\u8f66\u7684\u6570\u636e\u7b49\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u2728 \u987a\u5e26\u4e00\u63d0\uff1a\u5173\u4e8e\u201c\u503c\u4f20\u9012\u201d\u7684\u6f84\u6e05<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u6700\u5e38\u7528\u7684\u7236\u5b50\u7ec4\u4ef6\u901a\u4fe1\u65b9\u5f0f\uff0cPinia\u5e76\u4e0d\u662f\u7528\u6765\u201c\u4f20\u9012\u503c\u201d\uff0c\u800c\u662f\u7528\u6765<strong>\u521b\u5efa\u4e00\u4efd\u5728\u5168\u5c40\u53ef\u8bbf\u95ee\u7684\u3001\u54cd\u5e94\u5f0f\u7684\u201c\u5171\u4eab\u503c\u201d<\/strong>\u3002\u5b83\u7ef4\u62a4\u7684\u662f\u5355\u4e00\u6570\u636e\u6e90\uff0c\u76f8\u6bd4\u4f20\u7edf\u7684 props\/emit\uff0c\u80fd\u6709\u6548\u964d\u4f4e\u5927\u578b\u9879\u76ee\u7684\u7ef4\u62a4\u6210\u672c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pinia \u548c EventBus \u5728\u5b9a\u4f4d\u4e0a\u5b8c\u5168\u4e0d\u540c\uff0c\u53ef\u4ee5\u8bf4 Pinia \u662f\u5904\u7406\u590d\u6742\u5e94\u7528\u72b6\u6001\u7684\u201c\u5168\u5c40\u4ed3\u5e93\u201d\uff0c\u800c EventBus \u66f4\u50cf\u4e00\u4e2a\u201c\u4e34\u65f6\u4f20\u8bdd\u5668\u201d\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u5c06\u5b83\u4eec\u7684\u533a\u522b\u603b\u7ed3\u4e3a\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcdc \u6838\u5fc3\u5b9a\u4f4d\uff1a\u72b6\u6001\u7ba1\u7406 vs. \u4e8b\u4ef6\u901a\u4fe1<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pinia (\u72b6\u6001\u7ba1\u7406)<\/strong>\uff1a\u5b83\u662f\u4e00\u4e2a\u5168\u5c40\u7684\u201c\u4ed3\u5e93\u201d\uff0c\u7528\u4e8e<strong>\u5b58\u50a8\u548c\u7ba1\u7406\u5e94\u7528\u7684\u72b6\u6001<\/strong>\u3002\u7ec4\u4ef6\u53ef\u4ee5\u4ece\u4ed3\u5e93\u91cc\u8bfb\u53d6\u6216\u4fee\u6539\u6570\u636e\uff0c\u8fd9\u4e9b\u6570\u636e\u662f<strong>\u54cd\u5e94\u5f0f<\/strong>\u7684\uff08\u5373\u6570\u636e\u53d8\u4e86\uff0c\u7528\u5230\u5b83\u7684\u7ec4\u4ef6\u4f1a\u81ea\u52a8\u66f4\u65b0\uff09\u3002<\/li>\n\n\n\n<li><strong>EventBus (\u4e8b\u4ef6\u901a\u4fe1)<\/strong>\uff1a\u5b83\u50cf\u4e00\u4e2a\u201c<strong>\u5e7f\u64ad\u7cfb\u7edf<\/strong>\u201d\u3002\u4e00\u4e2a\u7ec4\u4ef6\u53ef\u4ee5\u201c\u5e7f\u64ad\u201d\u4e00\u4e2a\u4e8b\u4ef6\uff0c\u5176\u4ed6\u7ec4\u4ef6\u53ef\u4ee5\u201c\u6536\u542c\u201d\u8fd9\u4e2a\u4e8b\u4ef6\u5e76\u505a\u51fa\u53cd\u5e94\u3002\u5b83\u4fa7\u91cd\u7684\u662f<strong>\u884c\u4e3a\u89e6\u53d1<\/strong>\uff0c\u800c\u4e0d\u662f\u6570\u636e\u5b58\u50a8\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\uddec \u6838\u5fc3\u673a\u5236\u4e0e\u6570\u636e\u6d41\u5411<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pinia (\u72b6\u6001\u9a71\u52a8)<\/strong>\uff1a\u6240\u6709\u7684\u72b6\u6001\u90fd\u96c6\u4e2d\u5728Store\u4e2d\uff0c\u6570\u636e\u6d41\u5411\u662f<strong>\u5355\u5411\u3001\u6e05\u6670<\/strong>\u7684\u3002\u7ec4\u4ef6\u901a\u8fc7 <code>store.name = '\u65b0\u540d\u5b57'<\/code> \u7b49\u7b80\u5355\u65b9\u5f0f\u6765\u4fee\u6539\u72b6\u6001\uff0c\u5e76\u4e14Vue\u7684DevTools\u53ef\u4ee5\u7cbe\u786e\u8ffd\u8e2a\u6bcf\u4e00\u6b21\u53d8\u5316\u3002<\/li>\n\n\n\n<li><strong>EventBus (\u4e8b\u4ef6\u9a71\u52a8)<\/strong>\uff1a\u9075\u5faa\u7ecf\u5178\u7684<strong>\u53d1\u5e03-\u8ba2\u9605\uff08Pub\/Sub\uff09<\/strong> \u6a21\u5f0f\u3002\u6570\u636e\u6d41\u5411\u662f<strong>\u9690\u85cf\u4e14\u5206\u6563<\/strong>\u7684\uff0c\u4f60\u5f88\u96be\u76f4\u89c2\u5730\u770b\u51fa\u4e00\u4e2a\u4e8b\u4ef6\u7684\u89e6\u53d1\u4f1a\u5bf9\u54ea\u4e9b\u7ec4\u4ef6\u4ea7\u751f\u5f71\u54cd\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce6 \u6570\u636e\u6301\u4e45\u6027\u4e0e\u54cd\u5e94\u5f0f<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pinia (\u6301\u4e45\u4e14\u54cd\u5e94\u5f0f)<\/strong>\uff1a\u6570\u636e\u4f1a\u4e00\u76f4\u4fdd\u5b58\u5728Store\u4e2d\uff0c\u5e76\u4e14\u662f\u54cd\u5e94\u5f0f\u7684\u3002\u8fd9\u610f\u5473\u7740\u4efb\u4f55\u7ec4\u4ef6\u5bf9Store\u91cc\u6570\u636e\u7684\u4fee\u6539\uff0c\u90fd\u4f1a\u5373\u65f6\u4e14\u81ea\u52a8\u5730\u53cd\u6620\u5230\u5176\u4ed6\u6240\u6709\u5f15\u7528\u4e86\u8be5\u6570\u636e\u7684\u7ec4\u4ef6\u4e0a\u3002<\/li>\n\n\n\n<li><strong>EventBus (\u4e34\u65f6\u4e14\u975e\u54cd\u5e94\u5f0f)<\/strong>\uff1a\u4e8b\u4ef6\u672c\u8eab\u662f\u201c\u4e00\u6b21\u6027\u201d\u7684\uff0c\u5b83\u8d1f\u8d23\u4f20\u9012\u6570\u636e\uff0c\u4f46<strong>\u4e0d\u8d1f\u8d23\u4fdd\u5b58\u72b6\u6001<\/strong>\u3002\u6570\u636e\u4f20\u9012\u540e\uff0c\u5982\u679c\u6ca1\u6709\u88ab\u63a5\u6536\u65b9\u5b58\u50a8\uff0c\u5c31\u65e0\u6cd5\u518d\u8ffd\u8e2a\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udee0\ufe0f \u8c03\u8bd5\u3001\u7c7b\u578b\u4e0e\u5185\u5b58\u7ba1\u7406<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pinia (\u652f\u6301\u66f4\u5b8c\u5584)<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u8c03\u8bd5\u6027<\/strong>\uff1a\u501f\u52a9Vue DevTools\uff0c\u53ef\u4ee5\u6e05\u6670\u5730\u770b\u5230\u72b6\u6001\u7684\u53d8\u5316\u5386\u53f2\uff0c\u8ffd\u8e2a\u6027\u80fd\u66f4\u51fa\u8272\u3002<\/li>\n\n\n\n<li><strong>\u7c7b\u578b\u5b89\u5168<\/strong>\uff1a\u5bf9TypeScript\u63d0\u4f9b\u4e00\u6d41\u7684\u652f\u6301\uff0c\u5728\u7f16\u8f91\u5668\u4e2d\u5c31\u80fd\u83b7\u5f97\u5f3a\u5927\u7684\u7c7b\u578b\u63d0\u793a\uff0c\u80fd\u6709\u6548\u51cf\u5c11\u62fc\u5199\u9519\u8bef\u3002<\/li>\n\n\n\n<li><strong>\u5185\u5b58\u7ba1\u7406<\/strong>\uff1a\u7531Pinia\u81ea\u8eab\u7ba1\u7406\u76d1\u542c\u548c\u72b6\u6001\uff0c\u5f00\u53d1\u8005\u65e0\u9700\u624b\u52a8\u5e72\u9884\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>EventBus (\u652f\u6301\u8f83\u5f31)<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u8c03\u8bd5\u6027<\/strong>\uff1a\u7531\u4e8e\u4e8b\u4ef6\u7684\u89e6\u53d1\u548c\u76d1\u542c\u5206\u6563\u5728\u5404\u5904\uff0c\u5f53\u9879\u76ee\u89c4\u6a21\u53d8\u5927\u65f6\uff0c\u4ee3\u7801\u903b\u8f91\u4f1a\u96be\u4ee5\u8ffd\u8e2a\u3002<\/li>\n\n\n\n<li><strong>\u7c7b\u578b\u5b89\u5168<\/strong>\uff1a\u4e8b\u4ef6\u540d\u662f\u5b57\u7b26\u4e32\uff0c\u5bb9\u6613\u62fc\u5199\u9519\u8bef\uff0c\u4e14\u4e8b\u4ef6\u53c2\u6570\u6ca1\u6709\u7c7b\u578b\u7ea6\u675f\uff0c\u5bb9\u6613\u51fa\u9519\u3002<\/li>\n\n\n\n<li><strong>\u5185\u5b58\u7ba1\u7406<\/strong>\uff1a\u5f00\u53d1\u8005<strong>\u5fc5\u987b<\/strong>\u5728\u7ec4\u4ef6\u9500\u6bc1\u65f6\u624b\u52a8\u79fb\u9664\u4e8b\u4ef6\u76d1\u542c\uff0c\u5426\u5219\u6781\u6613\u5bfc\u81f4<strong>\u5185\u5b58\u6cc4\u6f0f<\/strong>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83c\udf33 \u53ef\u6269\u5c55\u6027\u4e0e\u67b6\u6784<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pinia (\u53ef\u6269\u5c55\u6027\u66f4\u5f3a)<\/strong>\uff1a\u5b83\u662f\u4e3a<strong>\u5927\u578b\u3001\u590d\u6742\u5e94\u7528<\/strong>\u8bbe\u8ba1\u7684\uff0c\u72b6\u6001\u9ad8\u5ea6\u96c6\u4e2d\uff0c\u903b\u8f91\u6e05\u6670\uff0c\u6613\u4e8e\u56e2\u961f\u534f\u4f5c\u548c\u540e\u671f\u7ef4\u62a4\u3002<\/li>\n\n\n\n<li><strong>EventBus (\u53ef\u6269\u5c55\u6027\u8f83\u5f31)<\/strong>\uff1a\u7b80\u5355\u573a\u666f\u4e0b\u5f88\u4fbf\u5229\uff0c\u4f46\u4f1a\u968f\u7740\u5e94\u7528\u589e\u957f\uff0c\u5f88\u5bb9\u6613\u6f14\u53d8\u6210\u96be\u4ee5\u7ef4\u62a4\u7684\u201c\u4e8b\u4ef6\u8718\u86db\u7f51\u201d\uff0c\u8ba9\u9879\u76ee\u9677\u5165\u6df7\u4e71\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcca \u603b\u7ed3\u5bf9\u6bd4<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u628a\u6838\u5fc3\u533a\u522b\u6574\u7406\u6210\u4e86\u4e00\u5f20\u8868\uff0c\u65b9\u4fbf\u4f60\u5bf9\u6bd4\u9009\u62e9\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-left\" data-align=\"left\">\u7279\u6027<\/th><th class=\"has-text-align-left\" data-align=\"left\">Pinia (\u5168\u5c40\u72b6\u6001\u7ba1\u7406)<\/th><th class=\"has-text-align-left\" data-align=\"left\">EventBus (\u4e8b\u4ef6\u603b\u7ebf)<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u6838\u5fc3\u601d\u60f3<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u96c6\u4e2d\u5f0f\u72b6\u6001\u7ba1\u7406<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u53d1\u5e03-\u8ba2\u9605\u4e8b\u4ef6\u901a\u4fe1<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u6570\u636e\u5b58\u50a8<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u2705 \u6301\u4e45\u5316\u5b58\u50a8<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u274c \u4e34\u65f6\u4f20\u9012\uff0c\u4e0d\u5b58\u50a8<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u54cd\u5e94\u5f0f<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u2705 \u662f<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u274c \u5426<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u6570\u636e\u6d41<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u6e05\u6670\u3001\u5355\u5411\u3001\u53ef\u8ffd\u8e2a<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u9690\u853d\u3001\u5206\u6563\u3001\u96be\u8ffd\u8e2a<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u8c03\u8bd5\u652f\u6301<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u2705 Vue DevTools \u5f3a\u529b\u652f\u6301<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u274c \u56f0\u96be\uff0c\u4f9d\u8d56 <code>console.log<\/code><\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>TypeScript<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u2705 \u539f\u751f\u652f\u6301\uff0c\u7c7b\u578b\u5b89\u5168<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u274c \u4e8b\u4ef6\u540d\u548c\u8f7d\u8377\u6613\u51fa\u9519<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u5185\u5b58\u98ce\u9669<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u4f4e<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u26a0\ufe0f \u9ad8\uff0c\u6613\u5185\u5b58\u6cc4\u6f0f<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>\u9002\u7528\u573a\u666f<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u4e2d\u5927\u578b\u5e94\u7528\u3001\u590d\u6742\u72b6\u6001\u5171\u4eab<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u5c0f\u578b\u9879\u76ee\u3001\u4e34\u65f6\u901a\u4fe1<\/td><\/tr><tr><td class=\"has-text-align-left\" data-align=\"left\"><strong>Vue 3 \u5b98\u65b9\u63a8\u8350<\/strong><\/td><td class=\"has-text-align-left\" data-align=\"left\">\u2705 \u662f<\/td><td class=\"has-text-align-left\" data-align=\"left\">\u274c \u5426 (Vue 3\u79fb\u9664\u4e86\u5185\u7f6e\u65b9\u6cd5)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udca1 \u4f7f\u7528\u573a\u666f\u4e0e\u5efa\u8bae<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u63a8\u8350\u4f7f\u7528 Pinia<\/strong>\uff1a\u5f53\u4f60\u7684\u5e94\u7528\u9700\u8981<strong>\u5728\u591a\u4e2a\u4e0d\u76f8\u5173\u7684\u7ec4\u4ef6\u95f4\u5171\u4eab\u548c\u4fee\u6539\u72b6\u6001<\/strong>\u65f6\uff08\u4f8b\u5982\u7528\u6237\u767b\u5f55\u4fe1\u606f\u3001\u8d2d\u7269\u8f66\u6570\u636e\u3001\u5e94\u7528\u4e3b\u9898\u8bbe\u7f6e\u7b49\uff09\u3002\u8fd9\u662f\u73b0\u4ee3 Vue 3 \u5e94\u7528\u7684\u6807\u51c6\u548c\u9996\u9009\u65b9\u6848\u3002<\/li>\n\n\n\n<li><strong>\u8003\u8651\u4f7f\u7528 mitt (\u73b0\u4ee3 EventBus \u5b9e\u73b0)<\/strong>\uff1a\u5728 Vue 3 \u4e2d\uff0c\u793e\u533a\u63a8\u8350\u4f7f\u7528 <code>mitt<\/code> \u8fd9\u6837\u7684\u5c0f\u5de7\u5e93\u6765\u5b9e\u73b0\u4e8b\u4ef6\u603b\u7ebf\u529f\u80fd\uff0c\u800c\u4e0d\u662f\u81ea\u5df1\u5b9e\u73b0\u3002\u5b83\u9002\u7528\u4e8e<strong>\u975e\u5e38\u8f7b\u91cf\u3001\u4e34\u65f6\u7684\u8de8\u7ec4\u4ef6\u901a\u4fe1<\/strong>\uff0c\u6bd4\u5982\u4e24\u4e2a\u975e\u7236\u5b50\u7ec4\u4ef6\u4e4b\u95f4\u7684\u4e00\u6b21\u7b80\u5355\u901a\u77e5\uff0c\u4e14\u4f60\u660e\u786e\u4e0d\u60f3\u5f15\u5165 Pinia\u3002<\/li>\n\n\n\n<li><strong>\u4ec0\u4e48\u60c5\u51b5\u4e0b\u53ef\u4ee5\u653e\u5fc3\u4f7f\u7528 EventBus \u6216 mitt\uff1f<\/strong> \u901a\u5e38\u662f<strong>\u539f\u578b\u5f00\u53d1<\/strong>\u3001<strong>\u5c0f\u578b\u6216\u5de5\u5177\u7c7b\u9879\u76ee<\/strong>\uff0c\u6216\u5728<strong>\u5c06 Vue 2 \u9879\u76ee\u8fc1\u79fb\u5230 Vue 3 \u7684\u8fc7\u6e21\u671f<\/strong>\uff0c\u4f5c\u4e3a\u4e34\u65f6\u65b9\u6848\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u26a0\ufe0f \u4f7f\u7528 EventBus \u7684\u5173\u952e\u63d0\u9192<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u5728\u7279\u5b9a\u573a\u666f\u4e0b\u4f60\u4ecd\u9700\u4f7f\u7528 EventBus\uff0c\u52a1\u5fc5\u4e25\u683c\u9075\u5b88\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5fc5\u987b\u5728 <code>onUnmounted<\/code> (Vue 3) \u6216 <code>beforeUnmount<\/code> \u94a9\u5b50\u4e2d\uff0c\u4f7f\u7528 <code>off<\/code> \u65b9\u6cd5\u6e05\u7406\u6389\u4f60\u6dfb\u52a0\u7684\u4e8b\u4ef6\u76d1\u542c\u5668<\/strong>\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u4e25\u91cd\u7684<strong>\u5185\u5b58\u6cc4\u6f0f<\/strong>\u548c\u610f\u60f3\u4e0d\u5230\u7684bug\u3002<\/li>\n\n\n\n<li>\u5efa\u8bae\u5c06\u6240\u6709\u7684\u4e8b\u4ef6\u540d\u79f0\u5b9a\u4e49\u4e3a<strong>\u5e38\u91cf<\/strong>\uff0c\u7edf\u4e00\u7ba1\u7406\uff0c\u907f\u514d\u62fc\u5199\u9519\u8bef\u548c\u547d\u540d\u51b2\u7a81\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u4f60\u7684\u5b66\u4e60\u9879\u76ee\u91cc\uff0c\u53ef\u4ee5\u5148\u7528 EventBus \u7406\u89e3\u5176\u201c\u5e7f\u64ad\u4e0e\u63a5\u6536\u201d\u7684\u6982\u5ff5\uff0c\u8fd9\u80fd\u5e2e\u52a9\u4f60\u66f4\u6df1\u523b\u5730\u4f53\u4f1a\u5230 Pinia \u5728\u5927\u578b\u9879\u76ee\u4e2d\u7684\u4ef7\u503c\u548c\u4f18\u52bf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u662f\u5728\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u5bf9\u8fd9\u4e24\u4e2a\u6982\u5ff5\u6709\u7591\u60d1\uff0c\u8fd8\u662f\u6b63\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u9762\u4e34\u9009\u578b\u5462\uff1f\u5927\u6982\u662f\u4ec0\u4e48\u7c7b\u578b\u7684\u9879\u76ee\uff1f\u6211\u53ef\u4ee5\u5e2e\u4f60\u5206\u6790\u4e00\u4e0b\u5230\u5e95\u7528\u54ea\u4e2a\u66f4\u5408\u9002\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53f3\u4e0a\u89d2\u90a3\u4e2a\u201c\u4fe1\u606f\u63d0\u793a\u6570\u5b57\u201d\uff08\u6bd4\u5982\u672a\u8bfb\u6d88\u606f\u6570\u91cf\uff09\uff0c<strong>\u6700\u9002\u5408\u7528 Pinia \u6765\u89e3\u51b3<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u539f\u56e0\u5f88\u7b80\u5355\uff1a\u8fd9\u4e2a\u6570\u5b57\u662f\u4e00\u4e2a<strong>\u5168\u5c40\u72b6\u6001<\/strong>\uff0c\u53ef\u80fd\u88ab\u591a\u4e2a\u7ec4\u4ef6\u8bbf\u95ee\u548c\u4fee\u6539\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5934\u90e8\u7ec4\u4ef6<\/strong>\uff1a\u663e\u793a\u8fd9\u4e2a\u6570\u5b57<\/li>\n\n\n\n<li><strong>\u6d88\u606f\u5217\u8868\u7ec4\u4ef6<\/strong>\uff1a\u5f53\u7528\u6237\u70b9\u51fb\u6d88\u606f\u6216\u6536\u5230\u65b0\u6d88\u606f\u65f6\uff0c\u9700\u8981\u4fee\u6539\u8fd9\u4e2a\u6570\u5b57<\/li>\n\n\n\n<li><strong>\u5176\u4ed6\u9875\u9762<\/strong>\uff1a\u4e5f\u53ef\u80fd\u9700\u8981\u77e5\u9053\u8fd9\u4e2a\u6570\u5b57\uff08\u5982\u9996\u9875\u7684\u5c0f\u7ea2\u70b9\uff09<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528 Pinia \u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u6570\u636e\u5171\u4eab\u548c\u54cd\u5e94\u5f0f\u66f4\u65b0\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7528 Pinia \u5b9e\u73b0\u901a\u77e5\u6570\u5b57\uff08\u793a\u4f8b\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u521b\u5efa Store<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ store\/notification.js\nimport { defineStore } from 'pinia'\n\nexport const useNotificationStore = defineStore('notification', {\n  state: () =&gt; ({\n    unreadCount: 0   \/\/ \u672a\u8bfb\u6570\u91cf\n  }),\n  actions: {\n    increment() {\n      this.unreadCount++\n    },\n    decrement() {\n      if (this.unreadCount &gt; 0) this.unreadCount--\n    },\n    setCount(count) {\n      this.unreadCount = count\n    },\n    async fetchUnreadCount() {\n      \/\/ \u8c03\u7528 API \u83b7\u53d6\u670d\u52a1\u5668\u4e0a\u7684\u672a\u8bfb\u6570\u91cf\n      \/\/ const res = await api.getUnreadCount()\n      \/\/ this.unreadCount = res.data.count\n    }\n  }\n})<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5728\u5934\u90e8\u7ec4\u4ef6\u4e2d\u663e\u793a\u6570\u5b57<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- Header.vue --&gt;\n&lt;template&gt;\n  &lt;div class=\"header\"&gt;\n    &lt;i class=\"message-icon\"&gt;&lt;\/i&gt;\n    &lt;span class=\"badge\" v-if=\"unreadCount &gt; 0\"&gt;{{ unreadCount }}&lt;\/span&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script setup&gt;\nimport { useNotificationStore } from '@\/store\/notification'\nimport { storeToRefs } from 'pinia'\n\nconst notificationStore = useNotificationStore()\nconst { unreadCount } = storeToRefs(notificationStore)\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u5728\u6d88\u606f\u5217\u8868\u4e2d\u4fee\u6539\u6570\u5b57<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- MessageList.vue --&gt;\n&lt;template&gt;\n  &lt;div&gt;\n    &lt;div v-for=\"msg in messages\" @click=\"markAsRead(msg.id)\"&gt;\n      {{ msg.content }}\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n\n&lt;script setup&gt;\nimport { useNotificationStore } from '@\/store\/notification'\n\nconst notificationStore = useNotificationStore()\n\nfunction markAsRead(id) {\n  \/\/ \u6807\u8bb0\u5df2\u8bfb\u903b\u8f91...\n  notificationStore.decrement()   \/\/ \u51cf\u5c11\u672a\u8bfb\u6570\u91cf\n}\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u4e0d\u7528 EventBus\uff1f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">EventBus \u4e5f\u80fd\u5b9e\u73b0\uff0c\u4f46\u6709\u51e0\u4e2a\u5f0a\u7aef\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u72b6\u6001\u4e0d\u6301\u4e45<\/strong>\uff1a\u6570\u5b57\u4fee\u6539\u540e\uff0c\u9875\u9762\u5237\u65b0\u5c31\u6ca1\u4e86\u3002Pinia \u53ef\u4ee5\u548c localStorage \u6216\u540e\u7aef\u540c\u6b65\u3002<\/li>\n\n\n\n<li><strong>\u96be\u4ee5\u8ffd\u8e2a<\/strong>\uff1a\u8c01\u4fee\u6539\u4e86\u6570\u5b57\uff0c\u5728\u4ee3\u7801\u91cc\u5f88\u96be\u4e00\u773c\u770b\u51fa\u3002<\/li>\n\n\n\n<li><strong>\u5bb9\u6613\u5185\u5b58\u6cc4\u6f0f<\/strong>\uff1a\u9700\u8981\u5728\u7ec4\u4ef6\u9500\u6bc1\u65f6\u624b\u52a8\u89e3\u7ed1\u4e8b\u4ef6\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528 EventBus \u5b9e\u73b0\u5c0f\u7ea2\u70b9\u901a\u5e38\u662f\u201c\u6536\u5230\u4e00\u4e2a\u901a\u77e5\u4e8b\u4ef6\uff0c\u7136\u540e\u4fee\u6539\u201d\uff0c\u4f46\u90a3\u4e2a\u201c\u4fee\u6539\u201d\u6700\u7ec8\u8fd8\u662f\u8981\u843d\u5728\u4e00\u4e2a\u5730\u65b9\u5b58\u50a8\u3002Pinia \u5c31\u662f\u90a3\u4e2a\u201c\u5730\u65b9\u201d\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u989d\u5916\u5efa\u8bae<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u7684\u5e94\u7528\u4e0d\u5927\uff0c\u800c\u4e14\u53ea\u6709\u5934\u90e8\u548c\u6d88\u606f\u9875\u4e24\u5904\u7528\u5230\u8fd9\u4e2a\u6570\u5b57\uff0c\u4e5f\u53ef\u4ee5\u7528 <code>provide\/inject<\/code> \u914d\u5408 <code>ref<\/code> \u6765\u5b9e\u73b0\u3002\u4f46\u4e00\u65e6\u7cfb\u7edf\u7a0d\u590d\u6742\uff0cPinia \u662f\u66f4\u4e13\u4e1a\u3001\u66f4\u7701\u5fc3\u7684\u9009\u62e9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u5df2\u7ecf\u5728\u770b Pinia \u548c EventBus \u7684\u533a\u522b\uff0c\u8bf4\u660e\u4f60\u6b63\u5728\u5b66\u4e60 Vue3 \u7684\u72b6\u6001\u7ba1\u7406\u3002\u76f4\u63a5\u7528 Pinia \u6765\u7ec3\u624b\u8fd9\u4e2a\u201c\u53f3\u4e0a\u89d2\u6570\u5b57\u201d\uff0c\u4f1a\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5b9e\u8df5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Vue3 \u91cc\uff0cPinia \u5e76\u4e0d\u662f\u4e3a\u4e86\u201c\u7236\u4f20\u5b50\u201d\u8fd9\u79cd\u7b80\u5355\u573a\u666f\u8bbe\u8ba1\u7684\u3002\u5b83\u7684\u6838\u5fc3\u804c\u8d23\u662f\u8de8\u5c42\u7ea7\u3001\u8de8\u7ec4\u4ef6\u5730\u5171\u4eab\u72b6\u6001\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4],"tags":[],"class_list":["post-4049","post","type-post","status-publish","format-standard","hentry","category-2","category-4"],"_links":{"self":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/4049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/comments?post=4049"}],"version-history":[{"count":1,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/4049\/revisions"}],"predecessor-version":[{"id":4050,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/posts\/4049\/revisions\/4050"}],"wp:attachment":[{"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/media?parent=4049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/categories?post=4049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gaigaiming.com\/index.php\/wp-json\/wp\/v2\/tags?post=4049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}