- Edit
- components/HelloWorld.vue to test HMR
-
- Check out - create-vue, the official Vue + Vite starter -
-- Learn more about IDE Support for Vue in the - Vue Docs Scaling up Guide. -
-Click on the Vite and Vue logos to learn more
- - - diff --git a/src/main.js b/src/main.js index 548b772..f65c35f 100644 --- a/src/main.js +++ b/src/main.js @@ -4,10 +4,13 @@ import App from './App.vue' import axios from 'axios' import ElementPlus from 'element-plus' import router from './router' +import { createPinia } from 'pinia' import 'element-plus/dist/index.css' +const pinia=createPinia() const app=createApp(App) +app.use(pinia) app.use(router) app.use(ElementPlus) app.config.globalProperties.$axios=axios diff --git a/src/store/token.js b/src/store/token.js new file mode 100644 index 0000000..498f5c3 --- /dev/null +++ b/src/store/token.js @@ -0,0 +1,21 @@ +import {defineStore} from 'pinia' + + +export const useTokenStore = defineStore('tokens', { + state: () => ({ + count: 0 + }), + actions: { + increment() { + this.count++ + }, + incrementAsync() { + setTimeout(() => { + this.increment() + }, 1000) + } + }, + getters: { + doubleCount: (state) => state.count * 2 + } + }) \ No newline at end of file diff --git a/src/views/about.vue b/src/views/about.vue index 9d60fb2..cb9eff6 100644 --- a/src/views/about.vue +++ b/src/views/about.vue @@ -1,5 +1,15 @@hello about
+Count: {{ tokenStore.count }}
hello home
+Count: {{ tokenStore.count }}
+ + +