1
财产“状态”我有以下功能:遗漏的类型错误:无法读取的不确定
extractCountries: function() {
var newCountries = [];
_.forEach(this.props.countries, function(country) {
var monthTemp = Utils.thisMonthTemp(parseFloat(country["name"]["temperature"]));
if(parseFloat(country["name"]["safety"]) > this.state.minSafety &&
parseFloat(country["name"]["nature"]) > this.state.minNature &&
this.state.weather.min <= monthTemp &&
monthTemp <= this.state.weather.max) {
newCountries.push(country);
}
}).bind(this);
return newCountries;
}
上线parseFloat(country["name"]["safety"]) > this.state.minSafety &&
我得到:
Uncaught TypeError: Cannot read property 'state' of undefined
但我结合外部阵营object:
}).bind(this);
那么为什么会出现这种错误呢?
你不具约束力的功能本身。移动parens内的'bind'调用。目前,您正在对'_.forEach'的返回值调用'bind'。 –
谢谢。这解决了它。 – octavian