简体   繁体   中英

Can't get Library in Dart to work properly

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM