0
我試圖將值存儲到混合應用程序的本地存儲中。當我在桌面Web瀏覽器中運行應用程序時,但是當我在Android設備上運行相同的應用程序時,我無法看到與Web瀏覽器中相同的輸出。我認爲它沒有保存在本地存儲中。如何爲Cordova應用程序啓用本地存儲
有沒有什麼辦法可以解決這個問題,還是我必須啓用本地存儲?
這裏是我的代碼:
function deductBalance(){
var str;
var num_arr = [];
var elems = document.querySelectorAll('.cost-block-deduct');
elems.forEach(function(el) {
var nums = el.options[el.selectedIndex].value;
num_arr.push(nums)
});
console.log(num_arr);
var alvar1 = (Number.parseInt(num_arr.join("")));
localStorage.setItem("deducted", alvar1);
window.location.href = "home.html"
}
function todaysExpenses(){
document.getElementById("spent_points_today").innerHTML = localStorage.deducted ;
document.getElementById("earned_points_today").innerHTML = localStorage.balance;
document.getElementById("balance-remaining").innerHTML = localStorage.balance - localStorage.deducted;
document.getElementById("balance-remaining-month").innerHTML = localStorage.balance - localStorage.deducted;
}
檢查,如果本地存儲由瀏覽器支持還是不支持。 try local2tool.setItem(「mod」,「do」); alert(localStorage.removeItem(mod)); (e){ } catch(e){ alert(「No」); } – developerCK