我正在通过将我的文本转换为小写字母并将其索引与-1进行比较,以便为ReactJS
中的特定字段设置一些值,但我在JavaScript控制台中收到此错误:ReactJS toLowerCase不是函数
Uncaught TypeError: props.filterText.toLowerCase is not a function
var props = this.props;
var rows = this.props.episodes
.filter(function(episode){
return episode.title.toLowerCase().indexOf(props.filterText.toLowerCase()) > -1;
})
.map(function(episode){
return <EpisodeRow key={episode.title} episode={episode}/>
});
不props.filterText有什么价值? – nnnnnn
'episode.title'是一个字符串吗?尝试将episode.title.toString()。toLowerCase()或console.log的值赋予控制台。 – Chris
这是一个非常简单的错误 - 'props.filterText'不是一个字符串。只需在'props.filterText'的过滤器循环内执行一个'console.log',你就会发现它不是一个字符串。我的猜测是它将会是'undefined' – Adam