var vm = new Vue({
el:'#app',
data: {
// 问题数组
questionList: [
{
title: "转弯是让直行还是?"
},
{
title:"咖啡有用还是茶叶有用?"
},
{
title:"我的奋斗这一书籍是希特勒著作的对吗?"
}
],
// 当前下标
currentIndex: 0
},
methods:{
// 下一题
next: function() {
if (this.currentIndex+1 == this.questionList.length) {
alert('已经是最后一题了~');
return;
}
this.currentIndex++
}
}
})
<div id="app">
当前问题:>>> {{ questionList[currentIndex]['title'] }}
<button @click="next">下一题</button>
</div>