56

私はプロジェクトに取り組んでおり、JavaScript フレームワークを開発しています。元のコードは約700行なので、この行だけ貼り付けました。includes メソッドは、Internet Explorer では機能しません。これに対する解決策はありますか?

var row_cells = tbl_row.match(/<td[\s\S]*?<\/td>/g);

    row.Cells = new Array();
    if (onRowBindFuncText != null) { /*Fonksyon tanımlanmaışsa daha hızlı çalış*/

        var cellCount = 0;
        for (i = 0; i < row_cells.length; i++) {

            var cell = new Cell();
            $.each(this, function (k, v) {

                if ((row_cells[i]+"").includes("#Eval(" + k + ")")) {

                    cell.Keys.push(new Key(k,v));

...コードは続きます

4

8 に答える 8

48

@Infer-on は素晴らしい答えを示しましたが、特定の状況で問題があります。for-in ループを使用すると、追加した「includes」関数が返されます。

ここに別のポリフィルがあります。

if (!Array.prototype.includes) {
  Object.defineProperty(Array.prototype, "includes", {
    enumerable: false,
    value: function(obj) {
        var newArr = this.filter(function(el) {
          return el == obj;
        });
        return newArr.length > 0;
      }
  });
}
于 2016-09-28T10:09:13.110 に答える