[英]JSNI method in GWT
在出現這種情況之前,它一直有效:
JS端:
jsMethod : function(){...}
GWT Java端:
public static native void javaMethod(JavaScriptObject obj) /*-{
var test = null;
test = ... ;
test.jsMethod();
}-*/;
問題是當我嘗試做這樣的事情時
JS端
jsMethod : function(a, b){... return string}
GWT Java端
String a = 'yes'
String b = 'no'
public static native void javaMethod(JavaScriptObject obj) /*-{
var test = null;
test = ... ;
var testString = null;
testString = test.jsMethod(a, b);
}-*/;
我將把參數從GWT傳遞給JS,然后返回一個String,但我不知道該怎么做。 謝謝 。
就像Java。 返回一個字符串。
public static native String javaMethod(JavaScriptObject obj) /*-{
var test = null;
test = ... ;
var testString = null;
testString = test.jsMethod(a, b);
return testString;
}-*/;
您可以向本地JavaMethod添加參數
public static native String javaMethod(JavaScriptObject obj, String a, String b) /*-{
var test = null;
test = ... ;
var testString = null;
testString = test.jsMethod(a, b);
return testString;
}-*/;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.