I have a questionnaire with 60 questions, and I need to display 10 questions at a time.
But, I'm having trouble making it work even though I see some references on the internet.
The way I am doing, each time I click next(), 10 items are added to the v-for, but the previous 10 items remain on the page.
I'm doing this:
<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">Sim</div>
<div class="caption option no">Não</div>
</div>
</div>
</div>
<div class="action-row">
<button v-if="perpage == 60" @click="salvarRelato()"><span>Publicar</span></button>
<button v-if="perpage < 50" @click="previous()"><span>Anterior</span></button>
<button v-if="perpage < 50" @click="next()"><span>Próximo</span></button>
</div>
My data:
props: ['perguntas'],
data(){
return {
perpage: 10,
}
},
methods: {
next(){
this.perpage = this.perpage + 10;
},
previous(){
this.perpage = this.perpage - 10;
},
}
Can you help me ?