Dashboard.ts
import { defineStore } from 'pinia';
export const useGlobalAppIdStore = defineStore('myStore', {
state: () => ({
GlobalAppId: '',
}),
actions: {
async changeId(appId) {
this.GlobalAppId = appId
},
},
});
index.vue
import { useGlobalAppIdStore } from '@/store/modules/Dashboard';
const GlobalAppIdStore = useGlobalAppIdStore();
GlobalAppIdStore.changeId(e);//设置值
onMounted(() => {
configAppId.value = GlobalAppIdStore.GlobalAppId;//获取值
});