gpt4 book ai didi

angular - 在dart angular2的组件中使用纸张标签

转载 作者:行者123 更新时间:2023-12-03 02:53:43 27 4
gpt4 key购买 nike

我正在尝试在dart angular2组件中使用聚合物纸标签,但是无法。我在下面的代码中缺少什么?

在下面的代码中,在index.html模板中指定的纸张选项卡可以正常工作,但是main-app.html中的纸张选项卡格式不正确,并且在单击时没有任何适当的动画就会消失。

pubspec.yaml

name: tabs_test
version: 0.0.1
description: Test Paper Tabs
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: ^2.0.0-beta.13.1
polymer: ^1.0.0-rc.16
polymer_elements: ^1.0.0-rc.8
transformers:
- polymer:
entry_points: web/index.html
- angular2:
platform_directives:
- 'package:angular2/common.dart#COMMON_DIRECTIVES'
- 'package:angular2/common.dart#FORM_DIRECTIVES'
platform_pipes:
- 'package:angular2/common.dart#COMMON_PIPES'
entry_points: web/main.dart

index.html
<!DOCTYPE html>
<html>
<head>
<title>Tab Test</title>
<script defer src="main.dart" type="application/dart"></script>
</head>
<body>
<main-app></main-app>
<paper-tabs selected="0"> <!-- THESE WORK -->
<paper-tab>INDEX ITEM ONE</paper-tab>
<paper-tab>INDEX ITEM TWO</paper-tab>
<paper-tab>INDEX ITEM THREE</paper-tab>
</paper-tabs>
</body>
</html>

主镖
import 'package:polymer/polymer.dart';
import 'package:angular2/platform/browser.dart';
import 'package:tabs_test/views/main_app/main_app.dart';

main() async {
await initPolymer();
bootstrap(MainApp, []);
}

main_app.dart
import 'package:angular2/angular2.dart';
import 'package:polymer_elements/paper_tabs.dart';
import 'package:polymer_elements/paper_tab.dart';

@Component(selector: 'main-app',
templateUrl: 'main_app.html',
providers: const[],
directives: const []
)
class MainApp {
MainApp() { }
}

main_app.html
<paper-tabs selected="0"> <!-- THESE DO NOT WORK -->
<paper-tab>MA ITEM ONE</paper-tab>
<paper-tab>MA ITEM TWO</paper-tab>
<paper-tab>MA ITEM THREE</paper-tab>
</paper-tabs>

最佳答案

通常,将Polymer与Angular2结合使用时,您需要启用完整的阴影DOM

在其他脚本标签之前添加此标签

<script src="packages/web_components/webcomponents.js"></script>
<script>
/* this script must run before Polymer is imported */
window.Polymer = {
dom: 'shadow',
lazyRegister: true
};
</script>

有关此主题的更多详细信息,请参见 https://dart.academy/dart-angular-2-and-polymer-together/

Repo project on GitHub

关于angular - 在dart angular2的组件中使用纸张标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36720611/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com