关于 $apply () 的疑问
关于 data 中 errorMessage 的这段代码:
if (!this.username || !this.password)
{ this.errorMessage = '请填写账户名和密码'
return
}
和之后的这段:
if (authResponse.statusCode === 401) {
this.error = true
this.errorMessage = authResponse.data.message
this.$apply()
}
我的疑问是,教程里有说过对于异步调用时,要更新 data 中某个数据时必须调用一次 this.$apply(),那第一段修改的errorMessage 为啥没用$apply().
推荐文章: