直接复制
//store.js
// #ifndef VUE3
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
// #endif
// #ifdef VUE3
import { createStore } from 'vuex'
const store = createStore({
// #endif
state: {
test:"测试数据"
},
mutations: {
test(state, provider) {
uni.setStorageSync('TEST_CONFIG', '测试数据');
}
},
getters: {
},
actions: {
}
})
export default store
//main.js
//...................省略
export function createApp() {
const app = createSSRApp(App)
app.use(store)
return {
app
}
}