dart - 编译为JavaScript时不加载Polymer.dart

标签 dart dart-polymer

编译为javascript时,Polymer.dart遇到一些非常奇怪的问题。它在Dartium中运行良好。这个应用程式在几个月前确实运作正常。但是,从那时起,Polymer经历了许多更改,因此我不得不进行大量更改才能使其得以编译。我已经在Polymer 3.2到最新的pub中进行了尝试,所有行为都相同。我正在稳定分支上运行最新的Dart安装。

我收到以下Javascript错误:

TypeError: $document.register is not a function



在下面的js的最后一行。标签变量是“聚合物元素”。

})(H.convertDartClosureToJS(W._callAttributeChanged$closure(), 4)))};
proto = Object.create(baseConstructor.prototype, properties);
t2 = H.makeLeafDispatchRecord(interceptor);
Object.defineProperty(proto, init.dispatchPropertyName, {value: t2, enumerable: false,    writable: true, configurable: true});
options = {prototype: proto};
if (!t1)
options.extends = extendsTagName;
$document.register(tag, options); 

从我看到的结果来看,polyfills没有被加载,因此未声明document.register方法。

下面是我的HTML文件

<head>
    <script src="index.dart" type="application/dart"></script>

    <script src="packages/browser/dart.js"></script>
    <script src="packages/browser/interop.js"></script>
</head>

我的index.dart看起来像

void main() {
    window.alert("Dart Lives!");

    initPolymer().run(() => initPresentation());
}


void initPresentation() {
    //Show the first screen
}

在Javascript下运行时,出现警告框,并显示Javascript错误。因此,我认为基本的 Dart 环境没有任何问题。

最佳答案

编辑

这已经改变了。
最新答案在这里
Polymer querySelector working on DartVM but not in Chrome after compile

OLD

很难说。

我认为index.dart应该看起来像

<head>  
  <script type='application/dart'>
    export 'index.dart';
  </script>
</head>

要么

<body>

  ...
  <script type='application/dart' src='index.dart'></script>
</body>

https://code.google.com/p/dart/issues/detail?id=17546#c16

关于dart - 编译为JavaScript时不加载Polymer.dart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21341825/

相关文章:

dart - 如何将数据传递给 Dart 聚合物中新创建的元素?

dart - 如何以编程方式选择和禁用纸张按钮?

flutter - Dart列表未通过forEach循环更新

dart - FutureBuilder 与 setState 的结合使用

dart - 在 dartlang 中实例化 Blob

dart - 使用 polymer ui 元素选项卡选择选项卡时切换内容

css - 直接在 polymer 中设计元素样式是不好的做法吗?

dart - 如何设计核心覆盖层的样式?

flutter - Flutter:将Base64字符串图像url转换为File并在FileImage或相关小部件中使用

crud - Dart 可以用于基本的 CRUD Web 应用程序吗?