1
所以我得到了一些正常工作的Dart項目。但是當我嘗試使用web-ui時,什麼都不起作用。 我輸入我想要的,有什麼不對?Dart組件不工作 - 爲什麼我的設置錯誤?
所以這裏是代碼(這是一個從git中取得的例子)。
project.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Shout This!</title>
<link rel="stylesheet" href="project.css">
</head>
<body>
<h1>Shout This!</h1>
<input type="text" bind-value="shoutThis" placeholder="Shout This!">
<div> Length: {{ shoutThis.length }} </div>
<div> Shouted: {{ shoutThis.toUpperCase() }} </div>
<div> Substring: {{ (shoutThis.length >= 6) ?
shoutThis.substring(1, 5) :
shoutThis.substring(0, 0) }} </div>
<div> Palindromic: {{ palindrome() }} </div>
<script type="application/dart" src="project.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>
project.dart:
import 'dart:html';
import 'package:web_ui/web_ui.dart';
import 'package:web_ui/watcher.dart' as watchers;
String shoutThis='';
void main() {
window.alert('test');
}
String palindrome() {
var buffer = new StringBuffer(shoutThis);
for (int i = shoutThis.length - 1; i >= 0; i--) {
buffer.write(shoutThis[i]);
}
return buffer.toString();
}
當我啓動這個項目,我得到了我的測試信息顯示出來,但網絡用戶界面不工作,我得到這個:{{shoutThis.length}}文字顯示。
你建立了嗎?這些東西仍然是您在瀏覽器中無法找到的東西,所以您需要構建或使用擴展:http://www.dartlang.org/articles/web-ui/tools.html – 2013-03-18 00:41:44