I am getting error "Error in data(): "TypeError: Unable to get property 'questions' of undefined or null reference" found in---> Questions> at resources\assets\js\components\Questions.vue"
What I'm doing wrong here component is not rendered on the page. I am trying to add component from here
`<template>
<div class="ques_wrapper">
<div v-for="(question, index) in quiz.questions" class="ques_block">
</div>
</div>
</template>
<script>
export default { data() { return { quiz: { title: 'My quiz', questions: [ { text: "Question 1", responses: [ {text: 'Wrong, too bad.'}, {text: 'Right!', correct: true}, ] }, { text: "Question 2", responses: [ {text: 'Right answer', correct: true}, {text: 'Wrong answer'}, ] } ] }, questionIndex: 0, userResponses: Array(this.quiz.questions.length).fill(false) } },
// The view will trigger these methods on click
methods: {
// Go to next question
next: function() {
this.questionIndex++;
},
// Go to previous question
prev: function() {
this.questionIndex--;
},
// Return "true" count in userResponses
score: function() {
return this.userResponses.filter(function(val) { return val }).length;
}
}
}
</script>`
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community