gpt4 book ai didi

javascript - 变量没有在 vue js 中更新,显示变量未定义

转载 作者:搜寻专家 更新时间:2023-10-30 22:54:27 32 4
gpt4 key购买 nike

我正在尝试在 html 中绑定(bind) totalQuestions 变量的更新值。但它显示以下错误。谁能告诉我哪里做错了。

enter image description here

HTML

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

变量:

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();
}

最佳答案

你打错了:date() 应该是 data()

关于javascript - 变量没有在 vue js 中更新,显示变量未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56421582/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com