Dart 查询自定义元素时,将作为UnknowneElement返回

Dart 查询自定义元素时,将作为UnknowneElement返回,dart,dart-webui,polymer,dart-polymer,Dart,Dart Webui,Polymer,Dart Polymer,我定义了一个自定义元素,聊天视图,并将其显示在页面上: <!DOCTYPE html> <html> <head> <title>index</title> <script src="packages/polymer/boot.js"></script> <link rel="import" href="chat_view.html"> </head>

我定义了一个自定义元素,
聊天视图
,并将其显示在页面上:

<!DOCTYPE html>

<html>
  <head>
    <title>index</title>
     <script src="packages/polymer/boot.js"></script>
    <link rel="import" href="chat_view.html">
  </head>

  <body>   
    <chat-view id="chat">
    </chat-view>

    <script type="application/dart" src="index.dart"></script>
  </body>
</html>
前一行导致以下异常:

Exception: type 'UnknownElement' is not a subtype of type 'ChatView' of 'chatView'.

有没有一种方法可以查询我的自定义元素,使我得到一个ChatView对象,而不是UnknowneElement?

经过一些挖掘,我发现自定义元素实例是通过UnknowneElement的
xtag
属性访问的

final ChatView ChatView=query(#chat”).xtag

在JS中有一个“WebComponentsReady”事件触发。不确定Dart端口有什么。在元素升级并准备就绪之前,您将无法查询DOM,因此建议在立即执行工作之前等待此事件。
Exception: type 'UnknownElement' is not a subtype of type 'ChatView' of 'chatView'.