繁体   English   中英

dart2js的输出导致“ null不是对象”

[英]dart2js's output causes “null is not an object”

跑步后

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")

我认为它应该按原样工作,尽管事实并非如此。

弄清楚了。

我将已编译的javascript文件包括在html页面的标签内。 将其移动到身体的最底部可以固定所有内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM