0

こんにちは、javascript に問題があります。

コンソールの localStorage に情報を保存しようとすると、未定義のメソッド「プッシュ」というエラーが発生しました。

<script type="text/javascript">                  

//localStorage.clear(); // Clears the hard drive (database)
var oUsers = {aIds:[], aNames:[]}; 

// Default            
if(localStorage.sUsers){
    console.log('Users already in memory');
    // Get the string with users from the database and
    // convert it into an object, so we can use it
    oUsers = JSON.parse(localStorage.sUsers); 
} 

function SaveUser(){
    // Take the text and make it an object                          
    oUsers.aIds.push(document.getElementById("TxtId").value);
    oUsers.aNames.push(document.getElementById("TxtName").value);               
    localStorage.sUsers = JSON.stringify(oUsers);
    console.log(localStorage.sUsers);                
}              

</script>  
4

0 に答える 0