我在cordova中使用cordova-local-notifications插件工作。首先清除功能正在运行,但现在当我清除并重新启动应用程序时,通知全部显示......
这是我明确的功能:
$('.clearbtn').click(function(){
var arraylength = info.data;
arraylength.splice(0,arraylength.length);
console.log('clear',arraylength);
});
控制台日志显示数组中没有任何内容。这是console.log(info.data)
这是所有提醒页面:
$(document).on("pagebeforeshow","#all",function(){
var html = '';
for(var count = 0; count < info.data.length; count++){
console.log(info.data);
var time = new Date(info.data[count][3]);
var addHour = time.setHours(time.getHours());
var date = new Date(addHour);
// Hours part from the timestamp
var hours = date.getHours();
// Minutes part from the timestamp
var minutes = "0" + date.getMinutes();
// Will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes.substr(-2);
var imgPath = 'img/icons/alert.png';
html = html + "<tr><td class='img-table'><img src=" + imgPath + "></td>" + "<td><span class='time-aside'><strong>" + formattedTime + "</strong></span><h4>" + info.data[count][1] + "</h4><p>" + info.data[count][2] + "</p></td></tr>";
}
$('.clearbtn').click(function(){
var arraylength = info.data;
arraylength.splice(0,arraylength.length);
console.log('clear',arraylength);
});
$("table#notificationTable tbody").empty();
$("table#notificationTable tbody").append(html).closest("table#notificationTable").table("refresh").trigger("create");
});
我真的不明白,因为它之前有效,但我不知道为什么它不再存在!
答案 0 :(得分:0)
我必须清除localStorage以及..因为我将它作为字符串推送到localstorage。这是对函数的重写:
$('.clearbtn').click(function(){
var arraylength = info.data;
arraylength = 0;
localStorage.clear();
});