2017-05-24 5 views
0

私の会社の以前の開発者は、Vue.js先行型コンポーネントを書きました。すべてがInternet Explorer 11に入るまで、それで問題はないようです。keyup機能がバインドされている入力ユーザーが入力している文字を受け入れないことがあります。これは私が作業しているコードのパフォーマンス上の問題のようです。以下は、問題を引き起こしているコードです。すべて削除しても何もしない場合、入力に問題はありません。それをスピードアップするためのパフォーマンス提案はありますか?使用されてVueコンポーネント劣悪なIEパフォーマンス

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

私は答えはありませんが、 '@ input'イベントを使用するなどの助けになるかどうかをテストするためにイベントを変更しようとしましたか? –

答えて

0

両方mapfiltermapfilterfilterとして使用されている特別なことから、冗長です、本当に何もしていません。

これについて何:これはパフォーマンスへの影響を引き起こす理由を私は見ていないが、それは本当に私が見る唯一の問題だ、と述べた

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

(私はコメントかのようにこれを書かれていると思います私はできた)。

関連する問題