提交 c42877e1 编写于 作者: fxy060608's avatar fxy060608

chore: add store/index.js

上级 44b4ee3c
import { createSSRApp } from 'vue'
import App from './App.vue'
import createStore from './store/index'
import createStore from './store'
export function createApp() {
const app = createSSRApp(App)
......
import { createStore } from 'vuex'
// mock
function fetchItem(id) {
return new Promise((resolve) => {
setTimeout(() => {
resolve({
id,
title: 'title' + id,
})
}, 300)
})
}
export default () => {
return createStore({
state() {
return {
items: {},
}
},
actions: {
fetchItem({ commit }, id) {
return fetchItem(id).then((item) => {
commit('setItem', { id, item })
})
},
},
mutations: {
setItem(state, { id, item }) {
state.items[id] = item
},
},
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册