How to transfer data from component Vue Vuex?

Hello. I use Vuex in the application. In the component there is a CHECKBOX on which hangs v-bind. On Father monitor the changes in data which are tied to this checkbox and send in to STATE. When you move to the next component data in the STATE of course preserved, and the date in the previous component, are erased. So I wish that when you return to the previous component in the data DATES were still those CHECKBOXES that were previously selected were selected. Trying to CREATED to obtain data from the STATE and attributing to DATE, and it works, but generates errors. Tell me what the problem please

<template>
the <div>
 <template v-for="filter in size">
 <input type="checkbox"
class="filter-item__checkbox"
name="filter"
:value="filter"
v-model="selectedSize"
id="size"
>
 <label for="size">
{{filter}}
</label>

</template>
</div>
</template>

the <script>
 import {mapGetters} from 'vuex'

 export default {
 name: "AppSizeFilter",
 data () {
 return {
 selectedSize: []
}
},

 computed: {
...mapGetters([
"filtersSize"
]),
 size() {
 return this.filtersSize.values
},
 selectedFilters() {
 return this.$store.state.selected.filters
},

},
 watch: {
 selectedSize(size) {
 this.$store.dispatch('updateSize', size);
}
},
 created() {
 if(this.selectedSize.length === 0) {
 this.selectedSize = [...this.selectedFilters.selectedSize]
}
}
}
</script>
March 19th 20 at 08:29
2 answers
March 19th 20 at 08:31
<keep-alive> will help you, probably
March 19th 20 at 08:33

Find more questions by tags Vue.jsJavaScript