{"id":103,"date":"2021-01-18T20:28:41","date_gmt":"2021-01-18T12:28:41","guid":{"rendered":"http:\/\/gjweb.top\/?p=103"},"modified":"2021-01-18T20:28:42","modified_gmt":"2021-01-18T12:28:42","slug":"%e5%88%9b%e5%bb%bavuex%e4%bb%93%e5%ba%93","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=103","title":{"rendered":"\u521b\u5efaVuex\u4ed3\u5e93"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u5b89\u88c5vuex<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install vuex -S<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728mian.js\u4e2d\u5f15\u5165\u4ed3\u5e93\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import store&#91;\u81ea\u5b9a\u4e49\u540d\u79f0] from \".\/store\/index.js\"&#91;\u8def\u5f84]\nnew Vue({\n    store \/\/\u6ce8\u518cstore,\u4ee5\u4fbf\u5176\u4ed6\u7ec4\u4ef6\u90fd\u53ef\u4ee5\u8bbf\u95ee\n})<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u914d\u7f6e\u6587\u4ef6<\/h2>\n\n\n\n<p><strong>\u5728src\u4e0b\u65b0\u5efa\u6587\u4ef6\u5939\u547d\u540d\u4e3astore;\u5e76\u65b0\u5efa\u4e3aindex.js\u7684\u6587\u4ef6,modules\u6587\u4ef6\u5939\u548ccounterModule.vue\u6587\u4ef6<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import Vue from \"vue\"\nimport Vuex from \"vuex\"\nVue.urs(Vuex)\nimport CounterModule from \".\/modules\/counterModule\"\/\/\u5f15\u5165vuex\u4ed3\u5e93\u6a21\u5757\nlet store = new Vuex.Store({\n    \/\/\u7528\u6765\u7ba1\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u72b6\u6001\u7684\u65b9\u5f0f\n    modules:{\n        CounterModule\n    }\n})\nexport default store<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5vuex \u5728mian.js\u4e2d\u5f15\u5165\u4ed3\u5e93\u6587\u4ef6 \u914d\u7f6e\u6587\u4ef6 \u5728src\u4e0b\u65b0\u5efa\u6587\u4ef6\u5939\u547d\u540d\u4e3astore;\u5e76\u65b0\u5efa\u4e3ainde [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-vuex"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=103"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}