不知怎的,我无法构建我的第一个Dart Web组件示例。该项目非常简单,取自Seth blog。
首先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 --- 文件:/ C:/Projects/ProtonUiComponents/build.dart 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'.
然后使用Dart编辑器错误,index.html
根本无法运行(不是在Dartium或Javascript中):
我做错了什么?
更新: