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

convertObjectLiteralToSetOrMap为什么只转一层? #302

Open
yx-mike opened this issue May 19, 2023 · 1 comment
Open

convertObjectLiteralToSetOrMap为什么只转一层? #302

yx-mike opened this issue May 19, 2023 · 1 comment

Comments

@yx-mike
Copy link

yx-mike commented May 19, 2023

问题

我的fairProps有好几层
'fairData': { 'fairProps': { "adsk": null, "spoor": null, "title": null, "banners": [ { "renderTitle": "", "renderDesc": "", "positionIndex": null, "color": null, } ], "initIndex": null, "aspectRatio": 4.0344827586206895, "page": "hotPage", "tabName": null, }, },

但是在读取的时候会把错误:
op_idx is not a function

我自己调试了一下,发现convertObjectLiteralToSetOrMap只转了fairProps最外层的数据,把Object转成Map;但是内层的对象还是Object,但是fair_core.js和fair_jsbase.js没有在Object的原型增加__op_idx__方法。

convertObjectLiteralToSetOrMap为什么只转一层,如果fairProps数据层级很多怎么办?

目前我是自己去fair库里面改的。

环境信息

flutter doctor --verbose
[✓] Flutter (Channel vd/main, 2.5.1042, on macOS 13.3.1 22E772610a darwin-x64, locale zh-Hans-CN)
    • Flutter version 2.5.1042 at /Users/hxd/Documents/flutter/flutter
    • Upstream repository ssh://[email protected]:60022/flutter/flutter.git
    • Framework revision a8cad5e28c (7 months ago), 2022-10-27 11:59:08 +0800
    • Engine revision b3af521a05
    • Dart version 2.14.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
dependencies:
  fair: 3.0.0
@yx-mike
Copy link
Author

yx-mike commented May 30, 2023

后来我想了下,还是不修改js的convertObjectLiteralToSetOrMap方法了。

使用 对象+属性 的方式读取fairProps内部层次的数据。

`

Banner banner = Banner();

try {

  Banner tmpBanner = fairProps['banners'][i];

  banner.renderImage = tmpBanner.renderImage;

  banner.redirectUrl = tmpBanner.redirectUrl;

  banner.isExposured = false;

} catch (e) {

  banner.renderImage = jsonBanner['renderImage'];

  banner.redirectUrl = jsonBanner['redirectUrl'];

  banner.isExposured = false;

}

`

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

1 participant