【问题标题】:Programmatic custom element broken in dart polymer 0.9.5?飞镖聚合物 0.9.5 中的程序化自定义元素损坏?
【发布时间】:2014-04-24 05:42:05
【问题描述】:

在聚合物 0.8.5 中用于程序化自定义元素创建的 earlier solution 似乎在聚合物 0.9.5 中被破坏了。

如果我们修改standard click-counter example 以使用编程元素创建,如下所示:

main() {
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((LogRecord rec) {   
    print('${rec.loggerName}: ${rec.level.name}: ${rec.time}: ${rec.message}');
  });

  initPolymer();

  var clickCounter = new Element.tag('click-counter');     
  document.body.children.add(clickCounter);
}

点击事件正在正确调用 {{increment}} 方法,但 {{count}} 值未在 HTML 中更新。

【问题讨论】:

标签: dart dart-polymer polymer


【解决方案1】:

聚合物代码应该从

运行
import "package:polymer/polymer.dart";

main() {
  initPolymer().run(() {
    // code here works most of the time
    Polymer.onReady.then((value) {     
      // some things must wait until onReady callback is called
      // for an example look at the discussion linked below
    });
  });
}

simple tooltip working in dartium, not as javascript

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    相关资源
    最近更新 更多