这个demo虽然功能少,但是其知识点很精华 基本上vuex知识点大部分都在这里面了,麻雀虽小 五脏俱全
如果你觉的对你有帮助帮忙点个star谢谢 感谢大佬!
前端交流群740625675
vuex官方文档 https://vuex.vuejs.org/ 我觉的官方文档说明很详细
localStorage用来本地储存
const state={
home:localStorage["home"]?JSON.parse(localStorage["home"]): [],
item:localStorage["item"]?JSON.parse(localStorage["item"]): [],
}
export default state
const mutations={
[types.SET_SHIXIANG](state,data){
state.home.push(data)
localStorage.setItem("home",JSON.stringify(state.home));
},
[types.SET_YES](state,data){
state.item.push(data)
localStorage.setItem("item",JSON.stringify(state.item));
}
}
export default mutations
const actions={
setOrder ({commit}, data) {
commit('SET_SHIXIANG', data);
},
setYes({commit},data){
commit('SET_YES',data)
}
}
export default actions
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
前端实习生一枚,做的不好,还望大佬嘴下留情 轻喷 大佬我想要个star