我可以知道以下代码何时在联机示例中运行良好,但在本地运行时却不行。我正在使用淘汰赛3.0
var searchModel = {
searchQuery: ko.observable(''),
searchHandle: ko.dependentObservable(function () {
var search = this.searchQuery().toLowerCase();
//return ko.utils.arrayFilter(beers, function (beer) {
// return beer.name.toLowerCase().indexOf(search) >= 0;
//});
console.log(search);
}, searchModel)
}; <input data-bind="value: searchModel.searchQuery, valueUpdate: 'keyup'" />
答案 0 :(得分:0)
下面的代码应该按预期工作。
var searchModel = {
searchQuery: ko.observable(''),
};
searchModel.searchHandle = ko.dependentObservable(function () {
var search = this.searchQuery().toLowerCase();
//return ko.utils.arrayFilter(beers, function (beer) {
// return beer.name.toLowerCase().indexOf(search) >= 0;
//});
console.log(search);
}, searchModel)