在我的飞镖之旅中,我偶然发现了一个加载组件的“阻塞器”。
虽然我的组件定义如下:
<!DOCTYPE html>
<element name="x-foo" constructor="FooComponent" extends="button">
  <template>
    <button type="button" class="btn {{classes}}"> {{text}} </button>
   </template>
   <script type="application/dart">
   import 'package:web_ui/web_ui.dart';
   String classes = '';
   String text = '';
   class FooComponent extends WebComponent {
   }
   </script>
</element>
并引用组件如下:
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>example</title>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <!-- '../web/foo.html' or '../web/out/foo.html.dart' -->
    <link rel="components" href='foo.html'>
  </head>
  <body>
    <h1>example</h1>
    <p>Hello world from Dart!</p>
    <x-foo></x-foo>
    <script type="application/dart">void main() { }</script>
    <script type="text/javascript" src="dart.js"></script>
  </body>
</html>
而且我的构建脚本没有创建 html 文件(输出文件夹:foo.html.dart),我不确定我必须参考哪个文件。
该手册的声明性也不足以解决我的问题: http ://www.dartlang.org/articles/dart-web-components/spec.html#loading-components
引用组件的定义 (foo.html) 或其生成的输出 (foo.html.dart) 都不起作用。我还通过检查仔细检查了这两个文件的路径,这两个文件都下载了铬。
我的结论性问题:这个参考(链接元素href)是指向内部智能还是指向运行时的“物理”可用文件?如果是第二个,哪个(生成的(html/dart)或来源)?
为了避免误解,我添加了我的回购清单:
foo
  packages
  examples
    assets
    dart.js
    example.html
  web
    out
      foo.html.dart
    foo.html
  build.dart