Polymer.dart在编译为JavaScript时未加载

问题描述 投票:1回答:1

在编译为javascript时,我遇到了Polymer.dart的一些非常奇怪的问题。它在Dartium中运行良好。这个应用程序几个月前确实有效。然而,Polymer从那时起经历了很多变化,所以我不得不进行大量的更改才能让它进行编译。我已经在聚合物3.2中尝试了这个到最新版本的酒吧,所有行为都一样。我正在稳定分支上运行最新的Dart安装。

我收到以下Javascript错误:

TypeError:$ document.register不是函数

在下面的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); 

从我所看到的polyfill没有加载,所以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 dart-polymer
1个回答
0
投票

编辑

这已经改变了。 这是一个最新的答案 Polymer querySelector working on DartVM but not in Chrome after compile

很难说。

我认为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

© www.soinside.com 2019 - 2024. All rights reserved.