LoginSignup
tn-soccerball
@tn-soccerball

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Vue.jsの解説

Vue.jsからの質問です。
下記のコードの「 return this.questions[this.questionIndex];」
の自分の理解が、「Vueインスタンスの、questionsデータを指定して、......」
までしか理解できなかったのですが、[this.questionIndex]は何を表しているのでしょうか?

new Vue({
el: "#app",
data:{
questionIndex: 0,
questions: [
{
question: "gifted child",
answers: ["天才児","才能","贈り物"],
answer: 0
}
],
},
computed: {
currentQuestion: function() {
return this.questions[this.questionIndex];
}
},

0

1Answer

questionsという配列のquestionIndex番目を参照している。という意味になります。

0

Comments

  1. @tn-soccerball

    Questioner
    お返事ありがとうございます。
    それを this.questions[this.questionIndex]のように各括弧付きで連続で記述している部分はなにを表しているのでしょうか?
    連続の質問失礼致します。
  2. @tn-soccerball

    Questioner
    なるほど!わざわざありがとううございます!

Your answer might help someone💌