I'm trying to put in an array('allData') 2 array of objects from 'roomContent' and 'roomSurveys. And when i check with vue inspector my allData is well created but not filled with the elements I want...
My goal is to display the components (post-card and answer-card which are components) thanks to a array(allData) that I can handle but for that I have to insert in this array the post and survey's data with mapState.
here is my script:
import { mapState } from 'vuex'
import AnswerCard from '~/components/Answers/AnswerCard'
import PostCard from '~/components/Content/PostCard'
// // import DecodedTagInHour from '~/components/Graphics/DecodedTagInHour'
// import DecodedTagMap from '~/components/Map/DecodedTagMap'
export default {
name: 'ContentDisplay',
components: {
AnswerCard,
PostCard,
// DecodedTagInHour,
// DecodedTagMap
},
computed: {
...mapState('surveys', ['roomSurveys']),
...mapState('post', ['roomContent']),
},
mounted() {
this.allData.push(...this.roomSurveys, ...this.roomContent)
},
data() {
return {
allData: [],
}
},
here is my template :
<div v-for="data in allData" :key="data.id">
<post-card v-if="data.type === 'post'"
>
</post-card>
<answer-card v-if="data.type === 'survey'">
</answer-card>
</div>
and like u can see my array contains nothing : vue inspector
<post-card>
shouldn't you be passing some data as props to it?