我开始对此失去理智......
我要做的就是从Node
NodeList
private List<Node> excludeDraggedElement(JsArray<Node> jsNodeList) {
List<Node> nodeList = new ArrayList<>();
GWT.log(jsNodeList.length() + ""); // Prints: 1
for(int i = 0; i < jsNodeList.length(); i++) {
Element element = (Element)nodeList.get(i);
if(element == this.draggedElement.getElement()) {
continue;
}
nodeList.add(jsNodeList.get(i));
}
return nodeList;
}
正如您所料,输出是:
1
Uncaught java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
我还尝试使用splice
public native void remove(JsArray<?> removeFrom, int index, int count) /*-{
removeFrom.splice(index, count);
}-*/;
Uncaught TypeError: arr_0_g$.splice is not a function
知道如何解决这个问题吗?
答案 0 :(得分:1)
nodeList为空。所以nodeList.get(i)
会抛出异常。