添加store相关
This commit is contained in:
parent
d8aa49e417
commit
7044fb12d9
@ -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
21
src/store/store.js
Normal 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
|
Loading…
Reference in New Issue
Block a user