Родительский компонент
<template>
<div
class="container"
@click="onClick"
>
<RenderQuestions :questions="{getQuestionData}"/>
</div>
</template>
<script>
import {mapGetters} from 'vuex';
import RenderQuestions from './RenderQuestions.vue';
export default {
components: {RenderQuestions},
data() {
return {
test: "test",
};
},
computed: {
...mapGetters(['getUserData', 'getQuestionData']),
//Other computed properties
},
created() {
console.log(this.$store);
},
async mounted() {
await this.$store.dispatch('getUser');
await this.$store.dispatch('getQuestion', this.getUserData.data.step);
},
methods: {
onClick () {
console.log(this.getQuestionData);
}
},
};
</script>
Дочерний компонент, куда передаю данные
<template>
<section class="questions">
<h1
class="questions__title"
@click="onClick"
>
Ответь на вопросы
</h1>
<div class="questions__wrapper">
<p class="questions__text" />
<ul
v-if="questions && questions.answers.length"
class="questions__list"
>
<li
v-for="question in questions.answers"
:key="questions.answers.id"
class="todo-item"
>
{{ question }}
</li>
</ul>
</div>
</section>
</template>
<script>
import Question from './Question.vue';
export default {
components: {Question},
props: {
questions: {
type: Object,
required: true,
default() {
return { answers: [] };
}
},
},
data() {
return {
};
},
created(){
console.log(this.props);
},
mounted() {
console.log(this.props)
},
methods: {
onClick : () => {
console.log(this.props);
}
}
};
</script>
В mounted хочу вывести что приходит в props
mounted() {
console.log(this.props)
},