diff --git a/src/main.ts b/src/main.ts index 2a769bd..98d843c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,19 +1,18 @@ import { createApp } from 'vue' import App from './App.vue' import router from './router' -import store from './store' +import {vuexStore, piniaStore} from './store' // 移动端适配 import 'lib-flexible/flexible.js'; // 引入全局样式 import '@/assets/scss/index.scss'; + // 全局引入按需引入UI库 vant import { vantPlugins } from './plugins/vant.js' -//全局组件 +//全局公共组件 import components from './plugins/components.js'; -// import CustomHeader from 'components/CustomHeader/CustomHeader' - -createApp(App).use(store).use(router).use(vantPlugins).use(components).mount('#app') \ No newline at end of file +createApp(App).use(vuexStore).use(piniaStore).use(router).use(vantPlugins).use(components).mount('#app') \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index e7b4301..ca0cd98 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,9 +1,10 @@ import { createStore } from "vuex"; +import { createPinia } from "pinia" -const store = createStore({ +export const vuexStore = createStore({ state: { isLoading: false, - userNmae: "" + userName: "" }, getters: { @@ -14,7 +15,7 @@ const store = createStore({ }, getUserNmae(state,data) { - state.userNmae = data + state.userName = data } }, @@ -23,4 +24,6 @@ const store = createStore({ }, modules: {}, }); -export default store; + + +export const piniaStore = createPinia() diff --git a/src/store/testPinia.ts b/src/store/testPinia.ts new file mode 100644 index 0000000..c5572ee --- /dev/null +++ b/src/store/testPinia.ts @@ -0,0 +1,27 @@ +import { ref } from 'vue' +import { defineStore } from "pinia" +export const usePiniaState = defineStore('pinia', ()=>{ + const userName = ref('') + const getUserNmae = (data) => { + userName.value = data + } + return { userName, getUserNmae} +}) + + +// export const usePiniaState = defineStore({ +// id: 'textPinia', +// state: () => { +// return { +// userName: '' +// } +// }, +// getters: { + +// }, +// actions: { +// getUserNmae(data) { +// this.userName = data +// } +// } +// }) \ No newline at end of file diff --git a/src/views/about/About.vue b/src/views/about/About.vue index 55b3861..e6b2e85 100644 --- a/src/views/about/About.vue +++ b/src/views/about/About.vue @@ -1,15 +1,31 @@