不知何故,我无法构建我的第一个Dart组件示例。这个项目非常简单,取自赛斯博客。
首先,build.dart文件应该放在项目的根文件夹中(而不是web/文件夹中) <- -这是真的吗?
以下是代码:
Project
\--ui
\-- test_component.html
<!DOCTYPE html>
<html lang="en">
<body>
<element name="x-click-counter" constructor="CounterComponent" extends="div">
<template>
<button on-click="increment()">Click me</button>
<span>(click count: {{count}})</span>
</template>
<script type="application/dart" src="test_component.dart"></script>
</element>
<!-- more below... -->
</body>
</html>
\-- test_component.dart
library test_component;
import 'package:web_ui/web_ui.dart';
class CounterComponent extends WebComponent
{
int count = 0;
void increment(e)
{
count++;
}
}
\-- web
\-- index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="components" href="ui/test_component.html">
<title>Dart • TodoMVC</title>
</head>
<body>
<x-click-counter></x-click-counter>
<script type="application/dart">main() {}</script>
</body>
</html>
\-- build.dart
import 'dart:io';
import 'packages/web_ui/component_build.dart';
void main()
{
build(new Options().arguments, ['web/index.html']);
}就在我将build.dart移动到根文件夹之后,发生了奇怪的错误:
- 00:51:50 01/04/2013 build.dart - build.dart =web\index.html-build.dart返回的错误代码255
未明错误:类“_File”没有带有匹配参数的实例方法“open”。
NoSuchMethodError:传递给方法'open‘接收机的不正确的参数数:尝试调用的'_File@0x1da10ec4’实例:打开(模式:‘FileMode’的实例)找到:打开(模式)堆栈跟踪:
#0 Object.noSuchMethod (dart:core-patch:1884:25)
#1 ConsoleFileSystem.writeString (file:///C:/Projects/ProtonUiComponents/packages/web_ui/src/file_system/console.dart:22:43)
#2 writeFile (file:///C:/Projects/ProtonUiComponents/packages/web_ui/dwc.dart:103:27)
#3 emitFiles.<anonymous closure> (file:///C:/Projects/ProtonUiComponents/packages/web_ui/dwc.dart:91:35)
#4 List.forEach (dart:core-patch:1219:8)
#5 emitFiles (file:///C:/Projects/ProtonUiComponents/packages/web_ui/dwc.dart:91:18)
#6 run.<anonymous closure>.<anonymous closure> (file:///C:/Projects/ProtonUiComponents/packages/web_ui/dwc.dart:85:29)
#7 _ThenFuture._sendValue (dart:async:463:24)
#8 _FutureImpl._setValue (dart:async:361:26)
#9 _FutureListenerWrapper._sendValue (dart:async:221:21)
#10 _FutureImpl._setValue (dart:async:361:26)
#11 _FutureImpl._setOrChainValue (dart:async:437:16)
#12 _ThenFuture._sendValue (dart:async:473:21)
#13 _FutureImpl._setValue (dart:async:361:26)
#14 _FutureListenerWrapper._sendValue (dart:async:221:21)
#15 _FutureImpl._setValue (dart:async:361:26)
#16 _FutureImpl._setOrChainValue (dart:async:437:16)
#17 _ThenFuture._sendValue (dart:async:473:21)
#18 _FutureImpl._setValue (dart:async:361:26)
#19 _CompleterImpl.complete (dart:async:190:21)
#20 _FutureImpl._FutureImpl.wait.<anonymous closure> (dart:async:273:29)
#21 _ThenFuture._sendValue (dart:async:463:24)
#22 _FutureImpl._setValue (dart:async:361:26)
#23 _CatchErrorFuture._sendValue (dart:async:485:14)
#24 _FutureImpl._setValue (dart:async:361:26)
#25 Stream.reduce.<anonymous closure> (dart:async:699:23)如果手动运行build.dart,则在dwc.dart中接收并出错
type 'ConsoleFileSystem' is not a subtype of type 'FileSystem' of 'fileSystem'.
然后,index.html就无法运行了(无论是在Dartium中还是在Javascript中),而Dart编辑器错误:

我做错什么了?
更新:
发布于 2013-04-01 17:16:02
目前的编辑版本(截至2013年4月1日)为20602。更新到最新版本应该可以修复它。
http://dartlang.org/docs/editor
https://stackoverflow.com/questions/15735275
复制相似问题