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