Dart异常:已经注册(聚合物)元素x的原型 [英] Dart Exception: Already registered (Polymer) prototype for element x

查看:175
本文介绍了Dart异常:已经注册(聚合物)元素x的原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个共享相同dart文件的聚合元素。在dart文件中我声明了两个PolymerElement类。

I've two polymer elements that share the same dart file. In the dart file I declare both the PolymerElement classes.

直到聚合物0.15.0 + 1它工作正常。
我把项目更新为聚合物0.15.1,现在我得到这个异常:

Until polymer 0.15.0+1 it was working fine. I've updated the project to polymer 0.15.1 and now I get this exception:

Exception: Already registered (Polymer) prototype for element x

其中x是第一个聚合物。

Where x is the first polymer.

我认为聚合物变换器试图注册它两次,第一次扫描x聚合物html文件,第二次扫描其他元素html文件。

I think the polymer transformer is trying to register it two times, the first scanning the x polymer html file, the second when scanning the other element html file.

问题已在dart中公开: https://code.google.com/p/dart/issues/detail?id=21332

An issue has been open in dart: https://code.google.com/p/dart/issues/detail?id=21332

推荐答案

该问题已通过 Polymer Dart 的0.15.1 + 2版本解决 。

The issue has been "resolved" with the release 0.15.1+2 of Polymer Dart.

编译器现在会发出警告,如问题评论:这里真正的解决方案应该是将你的脚本文件放在自己的html文件中,并导入而不是你的脚本总之,你有以创建具有以下内容的HTML文件(例如,script_thats_used_multiple_times.html):

The compiler now throws a warning, and as stated in the issue comments: "The real solution for you here should be to put your script file in its own html file, and import that instead of your script. In summary you have to create an HTML file (e.g. script_thats_used_multiple_times.html) with the following content:

<!DOCTYPE html>
<script type="application/dart" src="script_thats_used_multiple_times.dart"></script>

然后当然从原来使用这个文件的所有聚合物组件中删除原始文件,

then of course delete the original from all polymer components that used this file previously and put the import above the

<link rel="import" href="script_thats_used_multiple_times.html">

这将导入先前创建的HTML文件。简单。

which will import previously created HTML file. Simple."

这篇关于Dart异常:已经注册(聚合物)元素x的原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆