不知何故,我无法构建我的第一个 Dart Web 组件示例。该项目非常简单,取自Seth 博客。
首先,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 --machine --changed=web\index.html --- file:/C:/Projects/ProtonUiComponents/build.dart build.dart 返回错误代码255
未捕获的错误:类“_File”没有具有匹配参数的实例方法“open”。
NoSuchMethodError:传递给名为“open”的方法的参数数量不正确接收方:“_File@0x1da10ec4”的实例尝试调用:open(模式:“FileMode”的实例)发现:open(模式)堆栈跟踪:
#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 编辑器错误:
我做错了什么?
更新:
- 我在 Windows 7 x64 上运行
- Dart 编辑器版本 0.4.2_r20259
- Dart SDK 版本 0.4.2.8_r20259