S
S
slfomin2020-07-11 12:53:47
Vue.js
slfomin, 2020-07-11 12:53:47

How to add reactive field to vuex store?

there is a filter storage in the form of an object with objects, in the mutation you need to set the filter to a value, but the 'value' property, in which the value is planned to be stored, has not been declared.
now, after receiving data via axios, I make the property reactive according to the manual, with the creation of a separate mutation

spoiler
setFilters(state, filters){
            Object.keys(filters).forEach((index) => {
                let value = {
                    min: filters[index].min,
                    max: filters[index].max,
                };
                filters[index] = Object.assign({}, filters[index], { 'value': value });
            });
            state.filters = filters;
        },

but I would like to create a reactive value property at the filter assignment stage, however, there Object.assign() will not create reactivity when directly entered into state.filters , and the example from the manual will not work and will start swearing that I am working with state ( state ) outside the mutation

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question