2016-03-26 22 views

答えて

2

問題はあなたのsyntaxである:

は、ここに私のコードです。この方法で使用する必要があります。

localStorage.setItem("age", x.age) 

alert(localStorage.getItem('age')); 

アイデアは簡単です。データを名前に格納しています。そして、同じ名前を使用してそれを取得します。

0

ブラウザで開発者ツールを開きます。コンソールを見てください。あなたの構文が正しい取得後

storage.setItem(keyName, keyValue); 

を::

var x = { 
    age: 37, 
    gender: "male", 
    income: 17000, 
}; 
localStorage.setItem("age", x.age); 
alert(localStorage.getItem('age')); 

Uncaught TypeError: Failed to execute 'setItem' on 'Storage': 2 arguments required, but only 1 present.

は次に述べていたthe manualを見て

関連する問題