data() {
return {
gradeList: [],
gradeCode: '',
}
},
created() {
this._getGradeList()
this._getParam()
},
methods: {
_getGradeList() {
let param = {
teacherCode: teacherCode
}
axios.post('/getGradeList', param).then((res) => {
if (res.status === ERR_OK) {
this.gradeList = res.data.data
this.gradeCode = this.gradeList[0].gradeCode
}
})
},
_getParam() {
console.log(this.gradeCode)
const param = {
gradeCode: this.gradeCode,
}
console.log(param)
return param
}
},
我的问题是在 _getGradeList()方法里打印this.gradeCode是4,但是在_getParam()方法里打印还是初始值'',不是4,想到是因为异步的原因,怎么解决呢