簡體   English   中英

JS 互操作適用於 DDC 但不適用於 Dart2JS

[英]JS Interop works with DDC but not with Dart2JS

Dart 2.7 build_runner: 1.7.3 build_web_compilers: 2.9.0

我已經使用包 js 為 GoJS 創建了一個接口: https : //github.com/jodinathan/gojs_dart/問題是它在 DDC 中完美運行,但在與 Dart2JS 一起使用時拋出異常。

這是您可以查看的小副本: https : //github.com/jodinathan/gojs_dart/tree/master/example/flowchart

錯誤似乎在行 ..bind(GoJSBinding('text').makeTwoWay()) 我認為它找不到 bind() 函數,但是,它可以在 DDC 中找到。

關於如何解決這個問題的任何想法?

問題出在 dart-sdk: https : //github.com/dart-lang/sdk/issues/40434

看起來 dart2js 在所有類上都需要一個外部工廠構造函數,而 dartdevc 則不需要。 因此,例如,對於今天遇到的第一個錯誤,您有一個這樣的類:

@JS('Node')
class GoJSNode extends GoJSPart {}

它應該是這樣的:

@JS('Node')
class GoJSNode extends GoJSPart {
  external factory GoJSNode();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM