聚合物+ Dart2js不工作 [英] Polymer + Dart2js Not Working
问题描述
当我使用Polymer库创建一个新的应用程序时,它会生成一个示例项目。该项目在Dartium中工作正常,但是当我编译它(使用 pub build
),它不工作了。
When I create a new application using the Polymer library, it generates a sample project. The project works just fine in Dartium, but when I compile it (using pub build
), it doesn't work anymore.
我得到两个404和一个未捕获的类型错误。
I get two 404's and an uncaught typeerror.
这是我的控制台输出在Chrome。
Here is my console output in Chrome.
GET file:///home/michael/Code/sample/build/web/packages/shadow_dom/shadow_dom.debug.js sample.html:1
GET file:///home/michael/Code/sample/build/web/packages/custom_element/custom-elements.debug.js sample.html:2
Uncaught TypeError: Object #<HTMLDocument> has no method 'registerElement' sample.html_bootstrap.dart.js:6681
wi sample.html_bootstrap.dart.js:6681
ei sample.html_bootstrap.dart.js:9102
Ok sample.html_bootstrap.dart.js:9099
QL sample.html_bootstrap.dart.js:2184
aX.vV sample.html_bootstrap.dart.js:759
Vg sample.html_bootstrap.dart.js:644
(anonymous function) sample.html_bootstrap.dart.js:12464
init.currentScript sample.html_bootstrap.dart.js:12444
(anonymous function) sample.html_bootstrap.dart.js:12458
(anonymous function) sample.html_bootstrap.dart.js:12585
在 build / web / packages /
,所以我不知道为什么我得到一个404。
These files exist in build/web/packages/
, so I'm not sure why I'm getting a 404.
这工作正常,我更新到最新的Dart SDK(开发渠道)。
This worked fine before I updated to the latest Dart SDK (dev channel). Is it just a bug in there, what might be going on?
感谢。
更新:
我看到一个 Dart问题,我遇到了另一个问题,因此我应用了他们的 fix 到示例项目,现在我只得到 Uncaught TypeError
。现在我的输出如下所示:
I saw a Dart issue that I was having another issue with, so I applied their fix to the sample project, and now I only get the Uncaught TypeError
. Now my output looks like this:
Uncaught TypeError: Object #<HTMLDocument> has no method 'registerElement' sample.html_bootstrap.dart.js:6518
wi sample.html_bootstrap.dart.js:6518
ei sample.html_bootstrap.dart.js:8949
Ok sample.html_bootstrap.dart.js:8946
QL sample.html_bootstrap.dart.js:2142
aX.vV sample.html_bootstrap.dart.js:725
Vg sample.html_bootstrap.dart.js:587
(anonymous function) sample.html_bootstrap.dart.js:12313
init.currentScript sample.html_bootstrap.dart.js:12293
(anonymous function) sample.html_bootstrap.dart.js:12307
(anonymous function) sample.html_bootstrap.dart.js:12434
推荐答案
我通过在聚合物上放置依赖项约束来工作。我的pubspec.yaml文件现在看起来像这样:
I got it to work by placing a dependency constraint on polymer. My pubspec.yaml file now looks like this:
name: sample
description: A sample Polymer application
dependencies:
browser: any
polymer: "0.9.5"
transformers:
- polymer:
entry_points: web/sample.html
这篇关于聚合物+ Dart2js不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!