Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过JSNI使用google gwt JsArrayInteger(JavaScriptObject)_Gwt_Collections - Fatal编程技术网

通过JSNI使用google gwt JsArrayInteger(JavaScriptObject)

通过JSNI使用google gwt JsArrayInteger(JavaScriptObject),gwt,collections,Gwt,Collections,我对gwt比较陌生,在使用JsArrayInteger时遇到问题。这是我的密码: package com.google.gwt.sample.stockwatcher.client; public class StockWatcher implements EntryPoint { JsArrayInteger a; public void onModuleLoad() { a = (JsArrayInteger) JsArrayInt

我对gwt比较陌生,在使用JsArrayInteger时遇到问题。这是我的密码:

  package com.google.gwt.sample.stockwatcher.client;    
  public class StockWatcher implements EntryPoint {
      JsArrayInteger a;
      public void onModuleLoad() {
          a = (JsArrayInteger) JsArrayInteger.createArray(); 
          a.push(1);
          a.push(2);
          a.push(4);
          a.push(5);
          test();
      }
      public static native void test() /*-{
          var p = [1,2,3,4,5,6];
          var q = this.@com.google.gwt.sample.stockwatcher.client.StockWatcher::a;
          alert(q);
          alert(p);
      }-*/;
    }
结果是“未定义”和[1,2,3,4,5,6],而不是[1,2,3,4,5]和[1,2,3,4,5,6]。我想使用字段a并处理该数组(将其传递给第三方库)

本教程没有解释如何使用默认的JavaScriptObjetcs。有人发现错误了吗

致以最良好的祝愿

迈克尔

  public static native void test() /*-{
      var p = [1,2,3,4,5,6];
      var q = this.@com.google.gwt.sample.stockwatcher.client.StockWatcher::a;
      alert(q);
      alert(p);
  }-*/;
请注意,此方法是
静态的
,但您指的是
。传入一个实例并使用它而不是
,或者将方法更改为非
静态


请注意,此方法是
静态的
,但您指的是
。要么传入一个实例并使用它而不是
,要么将该方法更改为非
静态

我真蠢。。。我在想一个复杂的问题。。。非常感谢你!如果JSNI代码能告诉我们,
这个
没有意义。。。但JS不是这样工作的。这就是为什么很多人一开始就使用GWT。我真是太蠢了。。。我在想一个复杂的问题。。。非常感谢你!如果JSNI代码能告诉我们,
这个
没有意义。。。但JS不是这样工作的。这就是为什么许多人首先使用GWT。