While working with Vue.js, I encountered an issue where I wanted to assign an array stored in the data variable roomFilters to the key -> items in the filter1 object. Unfortunately, my code is not functioning as expected. Even though I can access the array in the roomFilters state variable, I am unsure how to properly use it inside the object.
<script>
import { mapState, mapActions } from 'vuex';
import ns from '@/vue/store/namespaces';
export default {
data() {
return {
filterData: {
filter1: {
key: 'filter1',
title: 'Space Attributes',
criteriaType: 'Multivalue',
items: this.roomFilters,
itemsToShow: 2
},
}
};
},
computed: {
...mapState(ns.global, ['roomFilters'])
},
created() {
this.fetchRoomFilters();
},
methods: {
...mapActions(ns.global, ['fetchRoomFilters']),
}
};
</script>