1
我想在JavaScript中編譯我的項目。dart2js js代碼`undefined不是一個函數`
編纂工作,但在瀏覽器(Chrome),我有:
Uncaught TypeError: undefined is not a function client.dart.js:14753
J.get$length$asx client.dart.js:14753
InputStream.InputStream$4$byteOrder$length$start input_stream.dart:19
InputStream.static.InputStream$ input_stream.dart:17
DartAgnanAsk__get_data_closure.call$1 bzip2_decoder.dart:9
invokeClosure_closure0.call$0 js_helper.dart:1822
_IsolateContext.eval$1 isolate_helper.dart:355
_callInIsolate isolate_helper.dart:30
invokeClosure js_helper.dart:1822
(anonymous function)
編譯我使用這個命令:
dart2js -v --out=client.dart.js main.dart
而且dart2js -v --analyze-all --out=client.dart.js main.dart
得出:
Info: Option '--analyze-all' implies '--analyze-only'.
Info: Options [--out=client.dart.js] indicate that output is expected, but compilation is turned off by the option '--analyze-only'.
Info: Package root is file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Documents/GitHub/DartAgnan/web/dart/packages/
Info: Allowed library categories: {Client, Shared, Internal}
Info: Scanning library dart:_js_helper (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/_internal/lib/js_helper.dart)
Info: Scanning library dart:core (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/core/core.dart)
Info: Scanning library dart:_internal (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/internal/internal.dart)
Info: Scanning library dart:_js_primitives (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/_internal/lib/js_primitives.dart)
Info: Scanning library dart:_foreign_helper (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/_internal/lib/foreign_helper.dart)
Info: Scanning library dart:_interceptors (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/_internal/lib/interceptors.dart)
Info: Scanning library dart:collection (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/collection/collection.dart)
Info: Scanning library dart:math (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/math/math.dart)
Info: Scanning library dart:convert (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/convert/convert.dart)
Info: Scanning library dart:async (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/async/async.dart)
Info: Scanning library dart:_isolate_helper (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/_internal/lib/isolate_helper.dart)
Info: Scanning library dart:isolate (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/isolate/isolate.dart)
Info: Scanning library dart:_js_names (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/_internal/lib/js_names.dart)
Info: Analyzing file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Documents/GitHub/DartAgnan/web/dart/main.dart (1.3.6)
Info: Scanning library file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Documents/GitHub/DartAgnan/web/dart/main.dart
Info: Scanning library package:route_hierarchical/client.dart
Info: Scanning library dart:html (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/html/dart2js/html_dart2js.dart)
Info: Scanning library dart:html_common (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/html/html_common/html_common_dart2js.dart)
Info: Scanning library dart:web_gl (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/web_gl/dart2js/web_gl_dart2js.dart)
Info: Scanning library dart:_native_typed_data (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/typed_data/dart2js/native_typed_data_dart2js.dart)
Info: Scanning library dart:typed_data (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/typed_data/dart2js/typed_data_dart2js.dart)
Info: Scanning library file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/html/html_common/metadata.dart
Info: Scanning library dart:indexed_db (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart)
Info: Scanning library dart:svg (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/svg/dart2js/svg_dart2js.dart)
Info: Scanning library dart:web_audio (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/web_audio/dart2js/web_audio_dart2js.dart)
Info: Scanning library dart:web_sql (file:///Volumes/Data/nfs/zfs-student-4/users/2013/tcaron/Dart/Dart tools/dart/dart-sdk/lib/web_sql/dart2js/web_sql_dart2js.dart)
Info: Scanning library package:logging/logging.dart
Info: Scanning library package:collection/wrappers.dart
Info: Scanning library package:route_hierarchical/src/utils.dart
Info: Scanning library package:route_hierarchical/link_matcher.dart
Info: Scanning library package:route_hierarchical/click_handler.dart
Info: Scanning library package:route_hierarchical/url_matcher.dart
Info: Scanning library package:route_hierarchical/url_template.dart
Info: Scanning library package:DartAgnan/module/initMod.dart
Info: Scanning library package:DartAgnan/module/home/controller/homeCtrl.dart
Info: Scanning library package:DartAgnan/module/ask/controller/DartAgnanAsk.dart
Info: Scanning library package:archive/archive.dart
Info: Scanning library package:crypto/crypto.dart
Info: Resolving...
Info: Resolved 1495 elements.
Info: Resolved 4746 elements.
Info: Preserving names.
Info: Resolved 14467 elements.
Info: Resolved 50 native elements used, 531 native elements dead.
Hint: 1 warning(s) suppressed in package:route_hierarchical.
Info: LibraryLoader took 63msec
Info: Scanner took 195msec
Info: Diet Parser took 115msec
Info: Parser took 607msec
Info: Patching Parser took 16msec
Info: Resolver took 2402msec
Info: Closure Simplifier took 0msec
Info: Type checker took 346msec
Info: IR builder took 0msec
Info: Type inference took 0msec
Info: ConstantHandler took 393msec
Info: Deferred Loading took 0msec
Info: Unknown task took 0msec
Info: Enqueue took 283msec
Info: Dump Info took 0msec
Info: SSA builder took 0msec
Info: SSA optimizer took 0msec
Info: SSA code generator took 0msec
Info: CodeEmitter took 0msec
Info: Total compile-time 4978msec; unaccounted 558msec
當我使用pub build --mode=debug
:
Loading source assets...
Building DartAgnan...
[Info from Dart2JS]:
Compiling DartAgnan|web/dart/main.dart...
[Dart2JS on DartAgnan|web/dart/main.dart]:
1 warning(s) suppressed in package:route_hierarchical.
[Info from Dart2JS]:
Took 0:00:10.001875 to compile DartAgnan|web/dart/main.dart.
Built 514 files to "build".
你看到哪裏是我的錯?或者有更明確的調試命令? 謝謝。
你是什麼意思?或者有更明確的調試命令?當你使用'pub build --mode = debug'時你有同樣的錯誤嗎? 我不認爲問題是'build'。你已經在你的代碼中做了一些無法可靠地構建給JS的東西。 –
你是對的,它來自UTF8.decoder ...有一種替代方案可以通過websocket生成「List」嗎? –
Druxtan
對不起,還沒有玩過WebSockets。也許別人有一個想法。 –