导入元素依赖项的最佳方法是什么?

What is the best way to import an element dependency?

我想知道这是否是在 polymer-dart 中导入 html 依赖项的最佳方式。 我想以这种方式在 my-element 中使用 my-other-element

我的-element.dart:

@HtmlImport('my-element.html')
library mypackage.my_element;

import 'package:polymer/polymer.dart';
import 'package:web_components/web_components.dart' show HtmlImport;

// HERE I import the dart file
import 'my-other-element.dart'

@PolymerRegister('my-element')
class MyElement extends PolymerElement {
  MyElement.created() : super.created();

}

我的-element.html:

<!DOCTYPE html>

//HERE I import the element html
<link rel="import" href="my-other-element.html">

<dom-module id="my-element">
    <template>
        <my-other-element></my-other-element>
    </template>
    <script type="application/dart" src="my-element.dart"></script>
</dom-module>

使用 @HtmlImport(...) 然后仅使用 Darts import ...; 指令导入是推荐的方法。

还有:
不鼓励在 Dart 文件名中使用 -(破折号)。首选_(下划线)

你也不需要

<script type="application/dart" src="my-element.dart"></script>

在您的 <dom-module> 中,如果您按照上面的建议导入。