[英]Value in object won't change
const filterField = {
searchText: ''
//Empty value to change over time.
}
const renderNotes = function (notes, filters) {
const filteredNotes = notes.filter(function (note) {
return note.title.toLowerCase().includes(filters.searchText.toLowerCase())
})
console.log(filteredNotes)
}
renderNotes(habits, filterField)
//This function is supposed to change the value of the filteredField object.
document.querySelector('#search-text').addEventListener('input', function (e) {
filterField.searchText === e.target.value;
renderNotes(habits, filterField);
} )
The last method is supposed to change the value of the filterfield object.最后一种方法应该是改变过滤字段 object 的值。 But it won't change.但它不会改变。
I am following a tutorial on udemy and am stuck on this part.我正在关注 udemy 的教程,并被困在这一部分。
filterField.searchText === e.target.value;
Too many equal signs:等号太多:
change to改成
filterField.searchText = e.target.value;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.