每当我使用--release
选项为我的项目提供服务或构建它并在网页上运行该项目时,我都会得到此错误控制台,并且使用{{1} }编译器的所有功能都可以正常工作。
例如,当我单击按钮时会发生这种情况:
dartdevc
这些是我从Dart调用的jquery-3.3.1.slim.min.js:2 Uncaught TypeError: ((w.event.special[a.origType] || {}).handle || a.handler).apply is not a function
at HTMLDivElement.dispatch (jquery-3.3.1.slim.min.js:2)
at HTMLDivElement.v.handle (jquery-3.3.1.slim.min.js:2)
at Object.trigger (jquery-3.3.1.slim.min.js:2)
at HTMLDivElement.<anonymous> (jquery-3.3.1.slim.min.js:2)
at Function.each (jquery-3.3.1.slim.min.js:2)
at w.fn.init.each (jquery-3.3.1.slim.min.js:2)
at w.fn.init.trigger (jquery-3.3.1.slim.min.js:2)
at r.t.show (modal.js:117)
at HTMLDivElement.<anonymous> (modal.js:515)
at Function.each (jquery-3.3.1.slim.min.js:2)
dispatch @ jquery-3.3.1.slim.min.js:2
v.handle @ jquery-3.3.1.slim.min.js:2
trigger @ jquery-3.3.1.slim.min.js:2
(anonymous) @ jquery-3.3.1.slim.min.js:2
each @ jquery-3.3.1.slim.min.js:2
each @ jquery-3.3.1.slim.min.js:2
trigger @ jquery-3.3.1.slim.min.js:2
t.show @ modal.js:117
(anonymous) @ modal.js:515
each @ jquery-3.3.1.slim.min.js:2
each @ jquery-3.3.1.slim.min.js:2
r._jQueryInterface @ modal.js:498
cr @ index.dart.js:316
J.h4 @ index.dart.js:6202
dart.nN @ index.dart.js:6096
$1 @ index.dart.js:4961
m6 @ index.dart.js:980
(anonymous) @ index.dart.js:989
API:
js
这应该是造成此错误的代码:
@JS()
library js_helper;
import 'package:js/js.dart';
@anonymous
@JS()
class SnackbarParams {
external factory SnackbarParams({String text, String pos, String backgroundColor});
external String get text;
external String get pos;
external String get backgroundColor;
}
@JS('Snackbar')
class Snackbar{
external static void show(SnackbarParams obj);
}
@JS('\$')
external dynamic jQuery(query);
@JS()
@anonymous
class ModalElement {
external dynamic modal(String call);
external dynamic on(String event, Function callback);
}
@JS()
@anonymous
class jFormElement {
external dynamic serialize();
}
答案 0 :(得分:0)
最后,问题出在on
方法中,我需要将allowInterop
添加到Function