繁体   English   中英

ie9中的javascript函数参数

[英]javascript function argument in ie9

我正在尝试使用Node Web Toolkit框架中的.each功能来迭代数组。 在执行此操作的同时,将数组的每个元素传递为:

arrayName.each(function(ele){
    console.log(ele);
    //or
    console.log(arguments);
});

这使我在IE9中为null或为空。 谁能告诉我如何将数组的每个ele作为函数的参数传递? 还是有其他方法可以做到这一点?

'arrayName'变量的外观如何? nwtjs.each方法在特殊的节点集合上进行迭代(在其中查找“ nodes”属性),因此无法在普通数组上进行迭代。 如其示例所示: http : //nwtjs.github.io/nwt/manual.html-“ 节点集合”部分 ,首先需要获取对节点集合的引用,以便可以使用.each进行迭代:

// Creating a new collection
var els = n.all('#mymenu li');

// Iterate over each item in the collection
// Receives each element as an argument
els.each(function(el){
    console.log(el);
});

直接从文档中获取。 你检查了吗? 请尝试此代码。

// Creating a new collection
var els = n.all('#mymenu li');

// Iterate over each item in the collection
// Receives each element as an argument
els.each(function(el){
  console.log(el);
});

http://nwtjs.github.io/nwt/manual.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM