Answer the question
In order to leave comments, you need to log in
Why might a func type field be lost in vuex?
Good evening.
There is a storage and the filters field in it:
//...
const createStore = () => {
return new Vuex.Store({
state: {
jobs: [],
filters: {}
},
//...
actions: {
async nuxtServerInit({ commit }) {
const result = await api.getJobs()
commit("SET_JOBS", result.data)
commit("SET_FILTERS", filters)
}
}
})
}
export default {
incoming: {
approving: {
title: "Согласование",
filterFunc: function(iJob) {
return iJob.subject.match(/Согласуйте.*/)
}
}
//...
}
}
<template>
<div>
<!--тут всё ок, в хранилище оно есть-->
<h5>{{ this.$store.state.filters.incoming[$route.params.filter].title }}</h5>
<JobList :jobs = filteredJobs />
</div>
</template>
<script>
//...
export default {
data() {
return {
filters
}
},
computed: mapState({
filteredJobs: function(state) {
const filterName = this.$route.params.filter
//const filterFunc = this.filters.incoming[filterName].filterFunc // так РАБОТАЕТ
const filterFunc = state.filters.incoming[filterName].filterFunc // так НЕ работает
return jobs
}
}),
//...
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question