gpt4 book ai didi

javascript - jQuery.Deferred 异常 : Cannot read property 'split' of null TypeError: Cannot read property 'split' of null

转载 作者:行者123 更新时间:2023-12-01 03:27:54 24 4
gpt4 key购买 nike

我有一个带有数据表的 Thymeleaf 模板 (1.10.15)。我定义了这个数据表:

$(document).ready(function() {  

$('#deviceEventTable').dataTable( {
order: [[ 0, "desc" ]],
select: true,
bLengthChange: false,
stateSave: true,
pageLength: 20,
initComplete: function() {
var api = this.api();
var selected = localStorage.getItem( 'DataTables_selected' ).split(',');
selected.forEach(function(s) {
api.row(s).select();
})
}
});


table.on('select.dt deselect.dt', function() {
localStorage.setItem( 'DataTables_selected', table.rows( { selected: true }).toArray() )
})

} );

但是当我初始化表时出现此错误:

jQuery.Deferred exception: Cannot read property 'split' of null TypeError: Cannot read property 'split' of null

最佳答案

您正在获取null来自localStorage.getItem( 'DataTables_selected' )

在执行 split() 之前尝试添加检查

关于javascript - jQuery.Deferred 异常 : Cannot read property 'split' of null TypeError: Cannot read property 'split' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44716407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com