[英]Scala.js exporting abstract val/var
It seems that exporting abstract val/var with descendants like this doesn't work: 像这样导出带有后代的抽象val / var似乎不起作用:
@JSExportDescendentObjects
trait T {
@JSExport
val i: Int
@JSExport
var j: Int
}
class A extends T {
val i = 5
var j = 10
}
I get warnings no valid targets for annotation on value i - it is discarded unused
and A
's i
and j
are not seen from Javascript. 我收到警告,
no valid targets for annotation on value i - it is discarded unused
,并且从Javascript中看不到A
的i
和j
。 However, it is possible to export them via @JSExportAll
: 但是,可以通过
@JSExportAll
导出它们:
@JSExportDescendentObjects
@JSExportAll
trait T {
val i: Int
var j: Int
}
class A extends T {
val i = 5
var j = 10
}
It is fine now, no warnings and i
and j
are visible from JS. 现在很好,没有警告,并且从JS中可以看到
i
和j
。
def
s doesn't have such problem. def
s没有这个问题。 Why is this and how can I selectively export abstract val/var? 为什么会这样,如何选择导出抽象val / var?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.