2017-09-28 1 views
0

Ich habe lodash als Teil meines Segelprojekts. Es existierte bereits als Teil von Segeln. Ich habe es in meinem Controller am Anfang der Datei als solche erforderlich ..Alle Lodash Funktionen "Keine Funktion"

const lodash = require('lodash'); 

Aber egal, was ich tue, auch wenn die automatische Vervollständigung der Funktion schon sagt, etwas mit ihnen getan Sie die ganze app nimmt und der Fehler "... ist keine Funktion" Es ist erforderlich, Fein- und Segellifte. Ich habe versucht, Tests mit selbst einfache Dinge wie

lodash.foreach([1,2,3], function(a){ 
    sails.log.debug(a); 
}); 

... und das erzeugt exakt die gleichen Fehler.

+3

[. Die Funktion heißt 'forEach', nicht' foreach'] (https://lodash.com/docs/4.17.4#forEach) – Andy

Antwort

3

Sie falsch foreach.

Es ist forEach wie this:

_.forEach([1, 2], function(value) { 
    console.log(value); 
}); 
// => Logs `1` then `2`. 

_.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 
    console.log(key); 
}); 
// => Logs 'a' then 'b' (iteration order is not guaranteed). 
Verwandte Themen