1
我對gwt相對較新,並且使用JsArrayInteger時遇到問題。這是我的代碼:谷歌gwt JsArrayInteger(JavaScriptObject)通過JSNI使用
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 = [email protected]::a;
alert(q);
alert(p);
}-*/;
}
結果 '未定義' 和[1,2,3,4,5,6]而非[1,2,3,4,5]和[1,2 ,3,4,5,6]。我想使用字段a並在該數組上工作(將它傳遞給第三方庫)。
教程http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html沒有解釋如何使用默認JavaScriptObjetcs。有人發現錯誤嗎?
最好的問候,
邁克爾
我是多麼愚蠢......我雖然是一個複雜的問題......非常感謝! – Michael 2012-03-12 17:09:44
如果只有JSNI代碼可以告訴我們'this'沒有意義......但這不是JS的工作原理。這就是爲什麼很多人首先使用GWT。 – 2012-03-12 17:12:01