I am struggling with displaying 10 questions at a time from a questionnaire that contains a total of 60 questions.
Despite finding some references online, I am having difficulty getting it to work properly.
The issue I am facing is that when I click on next()
, 10 new items are added to the v-for
but the previous 10 items still remain on the page.
Here is my current implementation:
<div class="test-questions comp">
<div class="question" v-for="q in perguntas['questions']" v-if="q.id <= perpage">
<div class="statement">
{{q.id}}. {{q.text}}
</div>
<div class="options yes-no">
<div class="caption option yes">Yes</div>
<div class="caption option no">No</div>
</div>
</div>
</div>
<div class="action-row">
<button v-if="perpage == 60" @click="salvarRelato()"><span>Publish</span></button>
<button v-if="perpage < 50" @click="previous()"><span>Previous</span></button>
<button v-if="perpage < 50" @click="next()"><span>Next</span></button>
</div>
This is how I have structured my data:
props: ['perguntas'],
data(){
return {
perpage: 10,
}
},
methods: {
next(){
this.perpage = this.perpage + 10;
},
previous(){
this.perpage = this.perpage - 10;
},
}
Any assistance would be greatly appreciated!