How to introduce static pictures into vuex, or what better ideas do you have?

now the array of the carousel graph is taken from the background interface action dispatch.
now you want to add a local static image to the array, how to write it in store

Mar.10,2021

if the path array for storing the webcast image is already defined in state (suppose loopList), only needs to write a method to add images in mutations, the js code is as follows:


export default {
    namespace: true,
    state: {
        loopList: []
    },
    mutations: {
        // 
        getLoopList: (state, loopList) => {
            state.loopList = loopList;
        },

        // 
        addLoopList: (state, src) => {
            state.loopList.push(src);
        }
    },

    // action
    actions: {
        // 
        getLoopList: ({commit}) => {
            // ajax
            $http.get('/xxx/xxx').then(function (data) {
                commit('getLoopList', data);
            }, function (err) {
                console.log(err);
            });
        }
    }
};

suppose you want to add an address after an operation, and the code in the .vue file is as follows:

let path = 'your img url';
this.$store.commit('addLoopList', path);
Menu