无法让Dart中的Library正常工作 [英] Can't get Library in Dart to work properly
问题描述
我有一些文件,我想在一个库中。但它只是不工作或抛出异常。
让我们说,我有这些文件。
Lib.dart,1.dart,2.dart,3.dart,每一个都是一个html文件,它定义了聚合物元素。
// Lib.dart
library testLib;
import'dart:html';
part'1.dart';
part'2.dart';
part'3.dart';
/ * ...代码... * /
/ p>
// 1.dart 2.dart和3.dart
testLib的一部分;
/ * ...代码... * /
工作,我得到的消息:
'http:// localhost:8080 / 1.dart ':error:line 7 pos 6:url expected
testLib的一部分;
^:http:// localhost:8080 / 1.dart
answer: Dart编辑器:预期网址
并将我的1.html,2.html和3.html更改为:
// 1.html,2.html和3.html
/ * ... * /
< script type =application / dartsrc =Lib.dart>脚本>
但现在我得到这个异常:
打破异常:已注册(Polymer)原型的元素my-Lib
我不知道为什么它不工作或我做错了。
解决方案我不知道为什么你的
$ 之前加上注释。的一部分
你有一个库语句或导入或其他代码par
?您只能在
据我所知,应该有一个库用于一个聚合物元素。
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 abovepar of
? You can only have comments beforepart of
.As far as I know currently there is still the limitation that you should have one library for one polymer element.
这篇关于无法让Dart中的Library正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!