我的dart2js已编译Chrome打包应用程序与Uncaught Error: Instance of 'UnknownJavaScriptObject'
和ReferenceError: DartObject is not defined
崩溃。
完整的堆栈跟踪如下
Uncaught Error: Instance of 'UnknownJavaScriptObject' echo_mco.dart.js:7913
Stack Trace:
ReferenceError: DartObject is not defined
at dart._convertToDart (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:7422:34)
at JsObject.$index (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:7449:16)
at dart.J.$index$asx (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:8496:41)
at chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:8874:12
at Isolate.prototype.(anonymous function) (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:9412:37)
at chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:8871:25
at Isolate.prototype.(anonymous function) (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:9412:37)
at RawDatagramSocket_bind_closure.call$0 (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:3079:14)
at dart.Future_Future$sync (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:3381:28)
at dart.RawDatagramSocket.static.RawDatagramSocket_bind (chrome-extension://paadaccdfibbhkkhjaolagidoopakdik/echo_mco.dart.js:3070:18)
答案 0 :(得分:6)
这是由于未正确包含interop.js
脚本造成的。它必须包含在
<script src="packages/browser/interop.js"></script>
它必须先于所有其他与Dart相关的JavaScript包含。所以包含可能看起来像这样
<script src="packages/browser/interop.js"></script>
<script type="application/dart">export 'package:polymer/init.dart';</script>
<script src="packages/browser/dart.js"></script>
在使用Chrome包的Chrome打包应用中,包含可能如下所示
<script src="packages/browser/interop.js"></script>
<script src="packages/chrome/bootstrap.js" defer></script>
<script src="echo_mco.dart" type="application/dart"></script>
进行讨论和解决