【发布时间】:2019-03-31 10:11:57
【问题描述】:
使用:飞镖 2.0.0
如何为 AngularDart 创建组件?
我运气不好,看了https://github.com/dart-lang/angular_components
我做了以下步骤:
- stagehand package-simple
- 将
export添加到带有library <packageName>;的飞镖文件中 -
引用了
pubspec.yaml中的包您必须在
pubspec.yaml中依赖于build_runner。 dev_dependencies: build_runner: >=0.8.10 pubspec.yaml 中的build_web_compilers。 dev_dependencies: build_web_compilers: >=0.3.6请检查以下导入: `import 'package:<...>template.dart''
我尝试使用以下方式构建包:
webdev build
webdev could not run for this project.
You must have a dependency on `build_runner` in `pubspec.yaml`.
# pubspec.yaml
dev_dependencies:
build_runner: >=0.8.10 <2.0.0
You must have a dependency on `build_web_compilers` in `pubspec.yaml`.
# pubspec.yaml
dev_dependencies:
build_web_compilers: >=0.3.6 <0.5.0
注意:仅使用一个简单的类,它就可以工作 - 但不适用于 Web 组件:
这行得通:
class Awesome {
bool get isAwesome => true;
}
这不:
import 'package:angular/angular.dart';
@Component(
selector: 'my-card',
templateUrl: 'my_card.html',
styleUrls: ['my_card.css'],
directives: [coreDirectives],
// pipes: [commonPipes],
)
class MyCard {
var cardstring = 'My Card - string';
}
无论如何使用它时:
<my-card></my-card>
【问题讨论】:
标签: angular-dart