添加store相关

This commit is contained in:
huangge1199 2024-05-15 10:53:55 +08:00
parent d8aa49e417
commit 7044fb12d9
2 changed files with 23 additions and 0 deletions

View File

@ -3,9 +3,11 @@ import './assets/main.css'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/store.js'
const app = createApp(App)
app.use(router)
app.provide('store', store)
app.mount('#app')

21
src/store/store.js Normal file
View File

@ -0,0 +1,21 @@
import { createStore } from 'vuex'
const store = createStore({
state() {
return {
currentRoute: null
}
},
mutations: {
setCurrentRoute(state, route) {
state.currentRoute = route
}
},
getters: {
currentRoute(state) {
return state.currentRoute
}
}
})
export default store