Javascript 控制台不必要的错误消息是否会减慢网页速度?

Javascript 控制台不必要的错误消息是否会减慢网页速度?,javascript,html,node.js,handsontable,Javascript,Html,Node.js,Handsontable,我正在使用Handsontable在我的网页中显示一些表格,它工作正常,但随着时间的推移,当客户端离开页面时,页面会挂起,从而积累错误,例如 (我不能上传图片,但信息是这样的) 387 handsontable.full.min.js:34未捕获类型错误:无法读取null的属性'querySelector' at t.OverlyContaineSelement(handsontable.full.min.js:34) 在n.value时(handsontable.full.min.js:34)

我正在使用Handsontable在我的网页中显示一些表格,它工作正常,但随着时间的推移,当客户端离开页面时,页面会挂起,从而积累错误,例如

(我不能上传图片,但信息是这样的)

387 handsontable.full.min.js:34未捕获类型错误:无法读取null的属性'querySelector'
at t.OverlyContaineSelement(handsontable.full.min.js:34)
在n.value时(handsontable.full.min.js:34)
在n.value时(handsontable.full.min.js:40)
在n.value时(handsontable.full.min.js:40)
在HTMLDEVELENT。(handsontable.full.min.js:40)
在htmldevelment.i(handsontable.full.min.js:34)
它是否会导致页面比初始页面慢

这是我的代码中的handsontable部分


function table(data){
try {
    document.getElementById('data_view').innerHTML = null;
    const container = document.getElementById('data_view');
    hot = new Handsontable(container, {
    licenseKey: 'non-commercial-and-evaluation',
    data: data,
    //rowHeaders: true,
    colHeaders: 
 ['Area','WorkStation','Stepname','Commit','TechNode','Moves','WIP','Running','Hold','MTAS','Delta to Commit','Remarks','Delta to Commit'],
    //editor: false,
    columns: function(column) {
    var columnMeta = {};
    if (column === 0) {
      columnMeta.data = 'AreaName';
    } else if (column === 1) {
      columnMeta.data = 'workstation';
    } else if (column === 2) {
      columnMeta.data = 'Stepname';
    } else if (column === 3) {
      columnMeta.data = 'Commit';
    } else if (column === 4) {
      columnMeta.data = 'TechNode';
    } else if (column === 5) {
      columnMeta.data = 'Moves';
    } else if (column === 6) {
      columnMeta.data = 'Wip';
    } else if (column === 7) {
      columnMeta.data = 'Running';
    } else if (column === 8) {
      columnMeta.data = 'Hold';
    } else if (column === 9) {
      columnMeta.data = 'MTAS';     
    } else if (column === 10) {
      columnMeta.data = 'Delta to Commit';
    } else if (column === 11) {
      columnMeta.data = 'Remark';
      columnMeta.readOnly = false;
    }
    return columnMeta;
    },
    readOnly: false,
    overflow: 'hidden',
    contextMenu: true,
    afterSelection: function(r,c){
    selection = this.getDataAtRow(r);
    //localStorage.setItem("selection", selection);
    //sessionStorage.setItem("selection2", selection);
    //onsole.log(data)
    },
    contextMenu: {
    items: {
        'row_above': {},
        'row_below': {},
        'col_left': {},
        'col_right': {},
        'remove_row': {},
        'remove_col': {},
        'undo': {},
        'redo': {},
        'make_read_only': {},
        'alignment': {},
        'copy': {},
        'export': {
            name: 'Export to CSV',
            callback: function(key, options) {
            hot.getPlugin('exportFile').downloadFile('csv', {
            columnHeaders: true,
            overflow: 'hidden',
            filename: 'Commit_Download_' + JSON.stringify(sqlrefresh[0].last_refresh)
            })}
        },
        'lot_id_list': {
          name: 'Check Lot',
          callback: function() {
window.open("http://mfgrpa2:4000/lot_list?"+"Step="+selection[2].toString()+"Technode="+selection[4].toString(), "lot_list", "width=1500");
          }
        }
    }},
    dropdownMenu: true,
    filters: true,
    manualColumnResize: true,
    manualRowResize: true,
    columnSorting: true,
    formulas: true,
    minRows: 2,
    minCols: 12,
    minSpareRows: 1,
    //maxCols: 3,
    //colWidths: '100',
    //height: 320,
    //afterGetColHeader: addInput,
    cells: function (row, col) {
    var cellProperties = {};
    const cellValue = this.instance.getDataAtCell(row, col);
    if (col === 10){
        if ( cellValue > 0 ) {
          cellProperties.renderer = function (instance, td, row, col, prop, value, cellProperties) {
              Handsontable.renderers.TextRenderer.apply(this, arguments);
              td.style.fontWeight = 'bold';
              td.style.color = 'black';
              td.style.background = '#4FF635';
          }
        }
        else if ( cellValue < 0 ) {
          cellProperties.renderer = function (instance, td, row, col, prop, value, cellProperties) {
              Handsontable.renderers.TextRenderer.apply(this, arguments);
              td.style.fontWeight = 'bold';
              td.style.color = 'black';
              td.style.background = '#C84321';
          }
        }
        else {
        }
    }
    return cellProperties;
    }
    });
    }
    catch(e){
    }}


功能表(数据){
试一试{
document.getElementById('data_view')。innerHTML=null;
const container=document.getElementById('data_view');
hot=新的可手持设备(容器、{
许可证密钥:“非商业和评估”,
数据:数据,
//行标题:对,
列标题:
['Area'、'WorkStation'、'Stepname'、'Commit'、'TechNode'、'Moves'、'WIP'、'Running'、'Hold'、'MTAS'、'Delta to Commit'、'Comments'、'Delta to Commit'],
//艺术经纬:错,
列:函数(列){
var columnMeta={};
如果(列==0){
columnMeta.data='AreaName';
}else if(列===1){
columnMeta.data='工作站';
}else if(列===2){
columnMeta.data='Stepname';
}else if(列===3){
columnMeta.data='Commit';
}else if(列===4){
columnMeta.data='TechNode';
}else if(列===5){
columnMeta.data='Moves';
}else if(列===6){
columnMeta.data='Wip';
}else if(列===7){
columnMeta.data='正在运行';
}else if(列===8){
columnMeta.data='Hold';
}else if(列===9){
columnMeta.data='MTAS';
}else if(列===10){
columnMeta.data='Delta to Commit';
}else if(列===11){
columnMeta.data=‘备注’;
columnMeta.readOnly=false;
}
返回列元;
},
只读:false,
溢出:“隐藏”,
上下文菜单:正确,
余选:功能(r,c){
selection=this.getDataAtRow(r);
//setItem(“选择”,选择);
//sessionStorage.setItem(“selection2”,selection);
//onsole.log(数据)
},
上下文菜单:{
项目:{
'上面的第u行':{},
'下面的第u行':{},
“col_left”:{},
“col_right”:{},
'删除_行':{},
“删除列”:{},
“撤消”:{},
“重做”:{},
“使您只读”:{},
'对齐':{},
'复制':{},
“出口”:{
名称:“导出到CSV”,
回调:函数(键、选项){
hot.getPlugin('exportFile')。downloadFile('csv'{
专栏标题:对,
溢出:“隐藏”,
文件名:“提交下载”+JSON.stringify(sqlrefresh[0]。上次刷新)
})}
},
“地块id列表”:{
名称:'检查批',
回调:函数(){
窗口打开(“http://mfgrpa2:4000/lot_list?“+”Step=“+选择[2]。toString()+”Technode=“+选择[4]。toString(),“批次列表”,“宽度=1500”);
}
}
}},
下拉菜单:正确,
过滤器:是的,
是的,
manualRowResize:正确,
是的,
公式:对,
麻雀:2,
明科尔斯:12,
会议记录:1,
//马克斯:3,
//冷宽:“100”,
//身高:320,
//afterGetColHeader:addInput,
单元格:功能(行、列){
var cellProperties={};
const cellValue=this.instance.getDataAtCell(行,列);
如果(列===10){
如果(单元格值>0){
cellProperties.renderer=函数(实例、td、行、列、属性、值、cellProperties){
Handsontable.renderers.textrender.apply(这是参数);
td.style.fontwweight='bold';
td.style.color='黑色';
td.style.background='#4FF635';
}
}
else if(单元格值<0){
cellProperties.renderer=函数(实例、td、行、列、属性、值、cellProperties){
Handsontable.renderers.textrender.apply(这是参数);
td.style.fontwweight='bold';
td.style.color='黑色';
td.style.background='#C84321';
}
}
否则{
}
}
归还财产;
}
});
}
捕获(e){
}}

谢谢。

通常这对网站的性能没有问题,只是它不美观或不专业。您应该尝试修复错误或找到其他解决方案。

querySelector
似乎未在提供的代码中的任何位置使用。没有“不必要的错误消息”,它们都表示在JS执行过程中发生了错误。错误消息也不会减慢网页的速度。代码中的错误消息来自handsontable库,可能的原因是您没有将库所需的所有信息传递给它的某些函数。

function table(data){
try {
    document.getElementById('data_view').innerHTML = null;
    const container = document.getElementById('data_view');
    hot = new Handsontable(container, {
    licenseKey: 'non-commercial-and-evaluation',
    data: data,
    //rowHeaders: true,
    colHeaders: 
 ['Area','WorkStation','Stepname','Commit','TechNode','Moves','WIP','Running','Hold','MTAS','Delta to Commit','Remarks','Delta to Commit'],
    //editor: false,
    columns: function(column) {
    var columnMeta = {};
    if (column === 0) {
      columnMeta.data = 'AreaName';
    } else if (column === 1) {
      columnMeta.data = 'workstation';
    } else if (column === 2) {
      columnMeta.data = 'Stepname';
    } else if (column === 3) {
      columnMeta.data = 'Commit';
    } else if (column === 4) {
      columnMeta.data = 'TechNode';
    } else if (column === 5) {
      columnMeta.data = 'Moves';
    } else if (column === 6) {
      columnMeta.data = 'Wip';
    } else if (column === 7) {
      columnMeta.data = 'Running';
    } else if (column === 8) {
      columnMeta.data = 'Hold';
    } else if (column === 9) {
      columnMeta.data = 'MTAS';     
    } else if (column === 10) {
      columnMeta.data = 'Delta to Commit';
    } else if (column === 11) {
      columnMeta.data = 'Remark';
      columnMeta.readOnly = false;
    }
    return columnMeta;
    },
    readOnly: false,
    overflow: 'hidden',
    contextMenu: true,
    afterSelection: function(r,c){
    selection = this.getDataAtRow(r);
    //localStorage.setItem("selection", selection);
    //sessionStorage.setItem("selection2", selection);
    //onsole.log(data)
    },
    contextMenu: {
    items: {
        'row_above': {},
        'row_below': {},
        'col_left': {},
        'col_right': {},
        'remove_row': {},
        'remove_col': {},
        'undo': {},
        'redo': {},
        'make_read_only': {},
        'alignment': {},
        'copy': {},
        'export': {
            name: 'Export to CSV',
            callback: function(key, options) {
            hot.getPlugin('exportFile').downloadFile('csv', {
            columnHeaders: true,
            overflow: 'hidden',
            filename: 'Commit_Download_' + JSON.stringify(sqlrefresh[0].last_refresh)
            })}
        },
        'lot_id_list': {
          name: 'Check Lot',
          callback: function() {
window.open("http://mfgrpa2:4000/lot_list?"+"Step="+selection[2].toString()+"Technode="+selection[4].toString(), "lot_list", "width=1500");
          }
        }
    }},
    dropdownMenu: true,
    filters: true,
    manualColumnResize: true,
    manualRowResize: true,
    columnSorting: true,
    formulas: true,
    minRows: 2,
    minCols: 12,
    minSpareRows: 1,
    //maxCols: 3,
    //colWidths: '100',
    //height: 320,
    //afterGetColHeader: addInput,
    cells: function (row, col) {
    var cellProperties = {};
    const cellValue = this.instance.getDataAtCell(row, col);
    if (col === 10){
        if ( cellValue > 0 ) {
          cellProperties.renderer = function (instance, td, row, col, prop, value, cellProperties) {
              Handsontable.renderers.TextRenderer.apply(this, arguments);
              td.style.fontWeight = 'bold';
              td.style.color = 'black';
              td.style.background = '#4FF635';
          }
        }
        else if ( cellValue < 0 ) {
          cellProperties.renderer = function (instance, td, row, col, prop, value, cellProperties) {
              Handsontable.renderers.TextRenderer.apply(this, arguments);
              td.style.fontWeight = 'bold';
              td.style.color = 'black';
              td.style.background = '#C84321';
          }
        }
        else {
        }
    }
    return cellProperties;
    }
    });
    }
    catch(e){
    }}