如何在聚合物应用程序中实现主要功能

mic*_*ica 10 dart dart-polymer

我想在使用聚合物的应用程序中实现主要功能.

我试图在dart文件中实现main函数,其中实现了聚合物代码.代码未执行.

不允许包含带有主要功能的第二个飞镖脚本 -

我的错误在哪里?Tnx Mica.

Gün*_*uer 21

的index.html

 <head>
   <!-- <link rel="import" href="packages/polymer/polymer.html"> not necessary anymore (only in elements)-->
   <!-- <script src="packages/web_components/platform.js"></script>
        not necessary anymore with Polymer >= 0.14.0 -->
   <!-- <script src="packages/web_components/dart_support.js"></script> 
        not necessary anymore with Polymer >= 0.15.0 -->

   <!-- old -->
   <script type="application/dart">
      export 'package:polymer/init.dart';</script> 

   <!-- new  -->
   <script type="application/dart">export 'index.dart';</script>
 </head>
 <body>
   ...
   <!-- ... when you use a custom main method (see https://code.google.com/p/dart/issues/detail?id=17546#c16) -->
   <script type="application/dart" src="index.dart"></script>
 </body>
Run Code Online (Sandbox Code Playgroud)

index.dart

聚合物0.17.0(Polymer.js 1.0)

main() async {
  await initPolymer();
  // Any other code here.
}
Run Code Online (Sandbox Code Playgroud)

在Polymer 0.17.0之前

Polymer 0.16.1引入了一种更简单的初始化方法.而不是main()使用带注释的方法@whenPolymerReady

// >= Polymer 0.16.1
import 'package:polymer/polymer.dart';
export 'package:polymer/init.dart';

@whenPolymerReady
void onReady() {
  /// Custom setup code here.
}
Run Code Online (Sandbox Code Playgroud)

在Polymer.dart 0.16.1之前

// >= Polymer 0.16.0
import "package:polymer/polymer.dart";

main() {
  initPolymer().then((zone) => zone.run(() {
    // code here works most of the time
    Polymer.onReady.then((_) {     
      // some things must wait until onReady callback is called
      // for an example look at the discussion linked below
    });
  }));
}
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅https://pub.dartlang.org/packages/polymer上的Polymer 0.16.0的更改日志

在Polymer 0.16.0之前

// < Polymer 0.16.0    
import "package:polymer/polymer.dart";

main() {
  initPolymer().run(() {
    // code here works most of the time
    Polymer.onReady.then((_) {     
      // some things must wait until onReady callback is called
      // for an example look at the discussion linked below
    });
  });
}
Run Code Online (Sandbox Code Playgroud)

在dartium中工作的简单工具提示,而不是javascript