переменная не обновляется в vue js, показывая, что переменная не определена - PullRequest
1 голос
/ 03 июня 2019

Я пытаюсь связать обновленное значение переменной totalQuestions в HTML. но это показывает ниже ошибку. Может кто-нибудь сказать мне, где я сделал не так.

enter image description here

HTML

<label><span class="red-text">Question No: </span><span>1 out of {{totalQuestions}}</span>/</label>

Variable:

date() {
        return {
            examKey: '',
            questionsIds: '',
            duration: 0,
            questionList: [],
            totalQuestions: ''
        }
    },

Методы

methods: {
    loadQuestionSet: function() {
            this.examKey = this.$route.params.key;
            this.$http.get(baseUrl.BASE_URL + 'question-set/key/' + this.examKey).then(
                (resp) => {
                    this.duration = resp.data.duration;
                    this.questionsIds = resp.data.questionIds;
                    this.loadQuestions();
                },
                (err) => {
                    this.$router.push("/exam");
                }
            );
        },

        loadQuestions: function() {
            this.$http.post(baseUrl.BASE_URL + 'question/exam/questions', this.questionsIds).then(
                (resp) => {
                    this.questionList = resp.data;
                    this.totalQuestions = this.questionList.length
                },
                (err) => {
                    console.log(err);
                }
            );
        }
},
beforeMount: function() {
        this.loadQuestionSet();
    }

1 Ответ

4 голосов
/ 03 июня 2019

У вас есть опечатка: date() должно быть data().

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...