这是代码:
@computed
get user() {
if(!this.hasValidated)
this.reloadUserData();
return this.userData;
}
@action
reloadUserData() {
return new Promise(function(ok, err) {
if(!window.localStorage['atoken'])
err({id:24, detail:'User havn\'t logged in.'});
if(!window.localStorage['aprofile'])
apicall.get('user/detail').then((data)=>{
this.setProfile(data.data.content);
ok(true);
}).catch((derr)=>{
err({id:20, detail:derr});
});
else{
this.userData=JSON.parse(window.localStorage['aprofile']);
}
}.bind(this));
}
因此,主要目标是,当配置文件数据尚未验证时,我们将从服务器重新获取它,然后,在等待数据更改时,我们将从本地存储中提供缓存值。
Anddd....我的问题是,为什么它会给我一个“计算值不能调用动作函数”的东西?
谢谢!:D