为什么在使用自定义元素时会出现内部Dartium异常?

时间:2013-10-24 04:05:01

标签: dart dart-polymer

我在控制台中看到此错误:

Exception: InvalidStateError: Internal Dartium Exception
  PolymerDeclaration.registerType (package:polymer/src/declaration.dart:241:22)
  PolymerDeclaration.register (package:polymer/src/declaration.dart:175:17)
  PolymerDeclaration._register (package:polymer/src/declaration.dart:114:13)
  PolymerDeclaration.registerWhenReady (package:polymer/src/declaration.dart:109:14)
  _notifyType (package:polymer/src/declaration.dart:514:49)
  Polymer.register (package:polymer/src/instance.dart:64:16)
  _loadLibrary (package:polymer/src/loader.dart:177:25)

我有这样的代码:

@CustomTag('person-tag')
class PersonTag extends PolymerElement {

我的HTML就像这样:

<polymer-element name="person-tag" extends="li">

为什么我从Internal Dartium Exception收到此registerType错误?

1 个答案:

答案 0 :(得分:3)

您看到此错误是因为您的HTML显示为extends="li",但Dart代码仅展开PolymerElement

如果您在extends中使用polymer-element属性,那么您的Dart类也必须扩展相同类型的元素。

要解决问题中的问题,请更改Dart类:

@CustomTag('person-tag')
class PersonTag extends LIElement with Polymer, Observable {

现在PersonTag确实扩展了<li>