簡體   English   中英

Vue組件IE性能不佳

[英]Vue Component Poor IE Performance

在我的公司先前的開發者寫了一Vue.js預輸入組件,一切似乎與它的罰款,直到我到Internet Explorer 11,當輸入到具有輸入keyup綁定到它有時不接受字符的用戶功能正在輸入。 我正在使用的代碼似乎是性能問題。 下面是導致問題的代碼,如果我將其全部刪除並且什么也不做,則輸入沒有問題。 我有什么性能建議可以加快速度嗎?

    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})
    },

使用的mapfilter都是多余的,特別是因為map被用作filter並且filter實際上並沒有做任何事情。

那這個呢:

this.matches = this.options.filter(function(o) {
  return o[that.displayProp].toLowerCase().indexOf(lowSearch) > -1
})

就是說,我不明白為什么這會對性能產生影響,但這確實是我所看到的唯一問題(如果可以的話,我會寫為注釋)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM