[英]Vue Component Poor IE Performance
A previous developer at my company wrote a Vue.js typeahead component and everything seems to be fine with it until I get into Internet Explorer 11. When typing into an input that has keyup
function binded to it it sometimes doesn't accept characters a user is inputting. 在我的公司先前的开发者写了一Vue.js预输入组件,一切似乎与它的罚款,直到我到Internet Explorer 11,当输入到具有输入keyup
绑定到它有时不接受字符的用户功能正在输入。 This seems to be a performance issue with the code I am working with. 我正在使用的代码似乎是性能问题。 Below is the code that is causing the issues, if I remove it all and just do nothing the input has no issues. 下面是导致问题的代码,如果我将其全部删除并且什么也不做,则输入没有问题。 Are there any performance suggestions I can make to speed it up? 我有什么性能建议可以加快速度吗?
searchResults: function(e){
this.isShown = true
this.selectedIndex = 0
this.filterOptions()
if(this.wildcardSearch){
var searchObj = {}
searchObj[this.displayProp] = 'Search For: <strong>'+this.search+'</strong>'
this.matches.unshift(searchObj)
}
// Show first 5 results
this.matches = this.matches.splice(0,5)
},
filterOptions: function(){
var lowSearch = this.search.toLowerCase()
var that = this
if (this.search) // don't filter on empty string
this.matches = this.options.map(function(o){
if (o[that.displayProp].toLowerCase().indexOf(lowSearch) > -1)
return o
}).filter(function(o){return o})
},
Both map
and filter
being used is redundant, specially since map
is being used as filter
and filter
is not really doing anything. 使用的map
和filter
都是多余的,特别是因为map
被用作filter
并且filter
实际上并没有做任何事情。
What about this: 那这个呢:
this.matches = this.options.filter(function(o) {
return o[that.displayProp].toLowerCase().indexOf(lowSearch) > -1
})
That said, I don't see why this would cause a performance impact, but it's really the only issue I see (I'd have written this as a comment if I could). 就是说,我不明白为什么这会对性能产生影响,但这确实是我所看到的唯一问题(如果可以的话,我会写为注释)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.