运行后
private/dart/dart-sdk/bin/dart2js -m -o public/js/script.js private/dart/script.dart
生成的 javascript 返回
TypeError: 'null' is not an object (evaluating 'J.RE(a).gVs')
但是,未缩小的错误是
TypeError: 'null' is not an object (evaluating 'J.getInterceptor$x(receiver).get$onBlur')
这可能更有意义。
无论我使用 script.js 还是 script.compiled.js,它都会这样做。
飞镖代码是
import 'dart:html';
import 'dart:core';
void main() {
querySelector("#authorInput").onBlur.listen(updateSurname);
}
void updateSurname(Event e){
String author = (e.target as InputElement).value;
String surname = author.split(' ').last;
querySelector("#surnameInput").text = surname;
}
相关的haml是
.form-group
%label(for="authorInput") Author
%input.form-control#authorInput(type="text" name="author" placeholder="Enter author")
.form-group
%label(for="surnameInput") Surname
%input.form-control#surnameInput(type="text" name="surname" placeholder="Enter surname")
我相信它应该按原样工作,尽管显然不是这样。