2013-10-23 197 views
3

我生成了一個示例聚合物Web項目。增加了以下js文件。js互操作編譯與dart2js錯誤 - 未捕獲NoSuchMethodError:找不到方法:

jslib.js

在clickcounter.dart我加入依賴

import 'package:js/js.dart' as js; 

和改變增量()函數

void increment() { 
    js.context.testfunction(); 
    count++; 
} 

在clickcounter.html加js文件導入

<script src="jslib.js" type="text/javascript"></script> 

而且在主HTML文件中添加

<script src="packages/browser/interop.js"></script> 

在當Dartium執行它正常工作。 當我把它編譯成JavaScript但它給出了一個錯誤

Uncaught NoSuchMethodError : method not found: 'Symbol("testfunction")' 
Receiver: Instance of 'Proxy' 
Arguments: [] js_helper.dart:870 


Stack Trace: 
Error 
at Object.wrapException (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:4632:13) 
at Proxy.Object.noSuchMethod$1 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:33708:13) 
at Proxy_noSuchMethod_closure.call$0 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:109612:46) 
at Object.Proxy.static.Proxy__forward (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:109581:45) 
at Proxy.noSuchMethod$1 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:109492:14) 
at Proxy.Object.testfunction$0 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:56090:17) 
at ClickCounter.increment$0 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:7080:50) 
at CachedInvocation.invokeOn$2 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:6221:28) 
at JsInstanceMirror._invoke$4 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:12998:35) 
at JsInstanceMirror.invoke$3 (http://127.0.0.1:3030/testrun/out/web/testrun.html_bootstrap.dart.js:12963:17) 

回答

0

嘗試把你的參考interop.js高於編譯鏢文件和dart.js的:

<script type="text/javascript" src="path/to/interop.js"></script> 
<script type="text/javascript" src="path/to/main.dart.js"></script> 
<script type="text/javascript" src="path/to/dart.js"></script> 

我瞭解到這個來自Dart Issue # 15065,它解決了與我的dart:js庫有類似的錯誤。

相關問題