问题
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