2019-1-2 mobx的@computed属性和get 函数的区别

销户系统的继续开发

1.联动12-13写的
关于mobx里的各种属性究竟有啥意义一直没搞懂,下面针对@computed属性和get 函数的区别

// 检查是否存在校验成功的账户
   @computed
  get verifyPassedExist() {
    let result = false;
    for (let k in cancelAccountList) {
      let hasSuccess = this[cancelAccountList[k]].find(account => {
        return !account.checkResultInfo || account.checkResultInfo.length == 0;
      });
      if (hasSuccess) result = true;
    }
    return result;
  }

注意get函数返回的是一个值,所以调用的时候不能写调用函数的方式,而是return AccountModel.verifyPassedExist

猜你喜欢

转载自blog.csdn.net/qq_36620428/article/details/85677150
今日推荐