Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json 中 methodMap 生成有问题 #242

Open
zmtzawqlp opened this issue Mar 11, 2023 · 3 comments
Open

json 中 methodMap 生成有问题 #242

zmtzawqlp opened this issue Mar 11, 2023 · 3 comments

Comments

@zmtzawqlp
Copy link
Contributor

代码如下

  int _getIT() {
    return [
      2401,
      2502,
    ].indexOf(_getInfoType());
  }

  int _getInfoType() {
    if (item != null && item['infoType'] != null) {
      return item['infoType'];
    }
    return -1;
  }

生成的 methodMap 应该是错的,或者说不应该有。

  "methodMap": {
    "_getIT": {
      "pa": [
        "%(_getInfoType)"
      ]
    }
  }

截屏2023-03-11 11 33 54

@zmtzawqlp
Copy link
Contributor Author

看起来是 indexOf 的锅,换一种写法就好了。只能用if else

@yuelong0306
Copy link

我的方法不知道为什么不进methodMap里面

@lhp3851
Copy link

lhp3851 commented Apr 18, 2024

  1. int _getInfoType() 函数返回的是 int 类型
  2. item 里的 item['infoType'] 返回的值什么类型的,这里应该返回的也是 int 类型,如果是 string 类型的数字,需要转一下数字类型: int.parse("")

你试着检查一下这里是不是类型不匹配

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants