【问题标题】:TypeError: cannot call method 'forEach' of undefinedTypeError:无法调用未定义的方法“forEach”
【发布时间】:2014-04-02 07:15:29
【问题描述】:

当我尝试将静态目录添加到我的代码时,我收到此错误:

TypeError: cannot call method 'forEach' of undefined

谁能帮我解决这个问题?

['adobeair','applewebkit','bs3','chrome','css','font-awesome','hpwos','images','img','js', 'Opera', 'plugins'].forEach(function (dir)
{
    app.use('/template/'+dir, connect.static(__dirname+'/template/'+dir));
});

谢谢

【问题讨论】:

标签: javascript node.js foreach


【解决方案1】:

最好的办法——

var dirs = ['adobeair','applewebkit','bs3','chrome','css','font-awesome','hpwos','images','img','js', 'Opera', 'plugins'];

dirs.forEach(function(dir) { 

console.log('dir name : '+dir);

});

它正在工作或我:)

【讨论】:

    猜你喜欢
    • 2015-01-21
    • 2015-04-03
    • 2015-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多