Answer the question
In order to leave comments, you need to log in
Why are my props undefined?
parent component
<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() {
console.log(this.props)
},
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