-4
問題: 我想獲取localstorage值「car」,我想在其他頁面中獲得car = [「red」,「blue」]的結果,我想要將結果一個接一個地排列成數組。我該如何解決它?Javascript localstorage將值逐個獲取到數組中
page 1:
car = ["red","blue"];
localStorage.setItem("car", JSON.stringify(car));
Another Page:
var car1 = JSON.parse(localStorage.getItem("car"));
alert(car1[0])
****show two record at the same time , i want to put it into array like car1[0] = red; car1[1] = blue;
你甚至知道第一頁上的JSON.stringify調用是幹什麼的嗎?如果你這樣做,你不需要問這個。 – Touffy
這個問題很難說清楚。另一個元素在'car1 [1]'中。 – JJJ
你需要付出更多努力來解釋情況和具體問題。花些時間閱讀[問] – charlietfl