如何同时使用JavaScript中的多个方法
How to use multiple methods in JavaScript at the same time
我有一个输入,您可以在其中按名称搜索特定课程,为此我使用过滤,还有 includes()
方法,我的问题是我需要同时应用三种方法时间,第一个方法是toLowerCase()
,第二个是toUpperCase()
,最后一个方法是trim()
GetMyCourses() {
return this.courses.filter(value => {
return value.title.toLowerCase().includes(this.result);
});
},
如果你离开了toLowerCase
方法,那么搜索的时候就不大写了,反之亦然,另外,如果去掉这两个方法,那么搜索的时候就需要准确的搜索这个词
也将 this.result
转换为小写。
GetMyCourses() {
let result = this.result.toLowerCase()
return this.courses.filter(value => {
return value.title.toLowerCase().includes(result);
});
},
我有一个输入,您可以在其中按名称搜索特定课程,为此我使用过滤,还有 includes()
方法,我的问题是我需要同时应用三种方法时间,第一个方法是toLowerCase()
,第二个是toUpperCase()
,最后一个方法是trim()
GetMyCourses() {
return this.courses.filter(value => {
return value.title.toLowerCase().includes(this.result);
});
},
如果你离开了toLowerCase
方法,那么搜索的时候就不大写了,反之亦然,另外,如果去掉这两个方法,那么搜索的时候就需要准确的搜索这个词
也将 this.result
转换为小写。
GetMyCourses() {
let result = this.result.toLowerCase()
return this.courses.filter(value => {
return value.title.toLowerCase().includes(result);
});
},