vuex 公共数据存储


vuex 公共数据存储, 简单介绍一下怎么使用的(这是主要是配上一篇 Axios 请求配置统一封装(加入缓存机制)
代码如下
import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); export default new Vuex.Store({ state, mutations, actions }); // actions export default { setChangeStorageHistory (context, value) { context.commit('setChangeStorageHistory', value) }, setEmptyStorageHistory (context) { context.commit('setEmptyStorageHistory') } }; // mutations export default { setChangeStorageHistory (state, value) { const historyList = state.storageHistory; historyList.push(value); state.storageHistory = historyList; }, setEmptyStorageHistory (state) { state.storageHistory = []; }, set_searchValue (state, payload) { state.searchValue = payload; } }; // state export default { storageHistory: [], searchValue: '' };


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM