Can't get Library in Dart to work properly

血红的双手。 提交于 2020-01-15 12:43:57

问题


I have some files and I want them in one library. But it just doesnt work or throws Exceptions.

Let's say I have these files. Lib.dart, 1.dart, 2.dart, 3.dart and for each of them also an html file, which defines the polymer element.

// Lib.dart
library testLib;

import 'dart:html';

part '1.dart';
part '2.dart';
part '3.dart';

/* ... Code ... */

and

// 1.dart 2.dart and 3.dart
part of testLib;

/* ... Code ... */

It didnt work and i got the message:

'http://localhost:8080/1.dart': error: line 7 pos 6: url expected
part of testLib;
     ^: http://localhost:8080/1.dart

So I saw this answer: Dart editor: expected url

and I changed my 1.html, 2.html and 3.html to:

//  1.html, 2.html and 3.html
/* ... */
<script type="application/dart" src="Lib.dart"></script>

But now i get this Exception:

Breaking on exception: Already registered (Polymer) prototype for element my-Lib

I dont know why it does not work or what I did wrong there.


回答1:


I wonder why your part of is on line 7. Do you have a library statement or imports or other code above par of? You can only have comments before part of.

As far as I know currently there is still the limitation that you should have one library for one polymer element.



来源:https://stackoverflow.com/questions/26482193/cant-get-library-in-dart-to-work-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!