how to implement a main function in polymer apps

后端 未结 1 507
攒了一身酷
攒了一身酷 2020-11-22 11:25

I want to implement a main function in an app using polymer.

I tried to implement the main function in the dart file, where the polymer code is implemented. The code

1条回答
  •  伪装坚强ぢ
    2020-11-22 12:01

    index.html

     
       
       
       
    
       
        
    
       
       
     
     
       ...
       
       
     
    

    index.dart

    Polymer 0.17.0 (Polymer.js 1.0)

    main() async {
      await initPolymer();
      // Any other code here.
    }
    

    Before Polymer 0.17.0

    Polymer 0.16.1 introduces a simpler way of initialization. Instead of main() use a method annotated with @whenPolymerReady

    // >= Polymer 0.16.1
    import 'package:polymer/polymer.dart';
    export 'package:polymer/init.dart';
    
    @whenPolymerReady
    void onReady() {
      /// Custom setup code here.
    }
    

    Before 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
        });
      }));
    }
    

    For more details look at the changelog of Polymer 0.16.0 at https://pub.dartlang.org/packages/polymer

    Before 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
        });
      });
    }
    

    simple tooltip working in dartium, not as javascript

    0 讨论(0)
提交回复
热议问题