diff --git a/package-lock.json b/package-lock.json index 8d73976..3ff9606 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "dependencies": { "core-js": "^3.6.5", "vue": "^3.0.0", - "vue-router": "^4.0.8" + "vue-router": "^4.0.8", + "vuex": "^4.0.2" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.5.0", @@ -18390,6 +18391,17 @@ "dev": true, "license": "MIT" }, + "node_modules/vuex": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.0.2.tgz", + "integrity": "sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==", + "dependencies": { + "@vue/devtools-api": "^6.0.0-beta.11" + }, + "peerDependencies": { + "vue": "^3.0.2" + } + }, "node_modules/watchpack": { "version": "1.7.5", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.5.tgz", @@ -33116,6 +33128,14 @@ "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "dev": true }, + "vuex": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.0.2.tgz", + "integrity": "sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==", + "requires": { + "@vue/devtools-api": "^6.0.0-beta.11" + } + }, "watchpack": { "version": "1.7.5", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.5.tgz", diff --git a/package.json b/package.json index 698d483..f90712e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "dependencies": { "core-js": "^3.6.5", "vue": "^3.0.0", - "vue-router": "^4.0.8" + "vue-router": "^4.0.8", + "vuex": "^4.0.2" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.5.0", diff --git a/src/main.js b/src/main.js index 1b825a8..03192af 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,10 @@ import { createApp } from 'vue' import App from '@/App.vue' import router from '@/router' +import store from '@/store' const app = createApp(App) app.use(router) +app.use(store) app.mount('#app') diff --git a/src/store/datas/index.js b/src/store/datas/index.js new file mode 100644 index 0000000..1b512ef --- /dev/null +++ b/src/store/datas/index.js @@ -0,0 +1,17 @@ +const data = { + namespaced: true, + state () { + return { + count: 0 + } + }, + getters: { + }, + mutations: { + increment (state) { + state.count++ + } + } +} + +export default data diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..f26079b --- /dev/null +++ b/src/store/index.js @@ -0,0 +1,9 @@ +import { createStore } from 'vuex' +import dataModule from "./datas" + +// Create a new store instance. +const store = createStore({ + datas: dataModule, +}) + +export default store diff --git a/yarn.lock b/yarn.lock index ba4947c..75deb55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1532,7 +1532,7 @@ optionalDependencies: "prettier" "^1.18.2" -"@vue/devtools-api@^6.0.0-beta.10": +"@vue/devtools-api@^6.0.0-beta.10", "@vue/devtools-api@^6.0.0-beta.11": "integrity" "sha512-oZ0n/N4UWpkMvbR1OrBtu+YhaVADo+bYX5lxo9tou7h10p0+v2K9yzzaZATVr0lqHb7iY1wALfO8yojwg0MTHw==" "resolved" "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.0.0-beta.13.tgz" "version" "6.0.0-beta.13" @@ -9881,7 +9881,7 @@ "resolved" "https://registry.npmjs.org/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz" "version" "1.9.1" -"vue@^2 || ^3.0.0-0", "vue@^3.0.0", "vue@3.0.11": +"vue@^2 || ^3.0.0-0", "vue@^3.0.0", "vue@^3.0.2", "vue@3.0.11": "integrity" "sha512-3/eUi4InQz8MPzruHYSTQPxtM3LdZ1/S/BvaU021zBnZi0laRUyH6pfuE4wtUeLvI8wmUNwj5wrZFvbHUXL9dw==" "resolved" "https://registry.npmjs.org/vue/-/vue-3.0.11.tgz" "version" "3.0.11" @@ -9890,6 +9890,13 @@ "@vue/runtime-dom" "3.0.11" "@vue/shared" "3.0.11" +"vuex@^4.0.2": + "integrity" "sha512-M6r8uxELjZIK8kTKDGgZTYX/ahzblnzC4isU1tpmEuOIIKmV+TRdc+H4s8ds2NuZ7wpUTdGRzJRtoj+lI+pc0Q==" + "resolved" "https://registry.npmjs.org/vuex/-/vuex-4.0.2.tgz" + "version" "4.0.2" + dependencies: + "@vue/devtools-api" "^6.0.0-beta.11" + "watchpack-chokidar2@^2.0.1": "integrity" "sha512-nCFfBIPKr5Sh61s4LPpy1Wtfi0HE8isJ3d2Yb5/Ppw2P2B/3eVSEBjKfN0fmHJSK14+31KwMKmcrzs2GM4P0Ww==" "resolved" "https://registry.npmjs.org/watchpack-chokidar2/-/watchpack-chokidar2-2.0.1.tgz"