gpt4 book ai didi

dart - 使用ElementList长度和[]时的Dart2js警告

转载 作者:行者123 更新时间:2023-12-03 03:46:27 25 4
gpt4 key购买 nike

我是Dart的新手。为了熟悉Dart,我创建了此脚本。它与编辑器和pub服务一起正常工作。但是pub serve dart2js会记录这两个警告,我不明白:

  • 类'ElementList'中没有名为'length'的成员
  • 类ElementList
  • 中没有运算符'[]'

    coloring.dart:

    import 'dart:math';
    import 'dart:html';
    import 'dart:async';

    const String CLICK_ME = 'Click me to pause!';

    void randomColoring(StreamSubscription subscription) {

    final Random random = new Random();
    final Element intro = querySelector("#intro");
    final ElementList<Element> boxes = querySelectorAll('.box');
    final Element info = querySelector("#info");

    subscription.onData((eventValue) {
    var box = random.nextInt(boxes.length); /// WARNING
    var hexCssColor = random.nextInt(0xFFFFFF + 1).toRadixString(16)
    .padLeft(6, "0").toUpperCase();
    boxes[box].style.background = "#$hexCssColor"; /// WARNING
    info.text = eventValue.toString();
    print("box: $box - hexCssColor: $hexCssColor - count: $eventValue");
    });

    var text = intro.text;
    intro
    ..text = CLICK_ME
    ..onClick.listen((mouseEvent) {
    if (subscription.isPaused) {
    intro.text = CLICK_ME;
    subscription.resume();
    } else {
    intro.text = text;
    subscription.pause();
    }
    });
    }

    最佳答案

    [] https://code.google.com/p/dart/issues/detail?id=19628ElementList运算符存在一个错误(已于6月26日修复)。

    您正在使用哪个Dart版本?

    我无法找到有关length的信息,但我猜这是Dart2JS中的错误。
    您可以在http://dartbug.com/new报告它
    但也许[]错误的修复也适用于此。

    关于dart - 使用ElementList长度和[]时的Dart2js警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24713404/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com