2017-07-13 15 views
0

私は電子メールとユーザーのパスワードを保存しようとしています。ここで私は何が欠けているのですか?ここでchrome.storage.local.set /は正しく動作しませんか?

は私のHTMLです:

<input type="text" name="email" id="email" placeholder="E-mail" /> 
<input type="password" name="password" id="password" placeholder="Password" /> 
<button id="import">Import!</button> 
<script type="text/javascript" src="popup.js"></script> 

は、ここに私のJavaScriptのだ:

Strangly
chrome.storage.local.get('email', function(result) { 
    document.getElementById("email").value = result.value; 
}); 

chrome.storage.local.get('password', function(result) { 
    document.getElementById("password").value = result.value; 
}); 

document.getElementById("import").addEventListener("click", function() { 
    chrome.storage.local.set({'email': document.getElementById("email").value}); 
    chrome.storage.local.set({'password': document.getElementById("password").value}); 
} 

、私はページを更新すると、値が保存されていません。

+0

[ここで見る](https://stackoverflow.com/questions/13872542/chrome-chrome-storage-local-get-and-set)ここでは任意のヘルプ? – Constantine

+0

'console.log(result)'を試してみたところ、 'chrome.storage.local.get'は実際には' value'のないオブジェクトを返しています。私は答えを投稿します。 –

答えて

0

それは次のようになります。

chrome.storage.local.get('email', function(result) { 
    document.getElementById("email").value = result.email; 
}); 

chrome.storage.local.get('password', function(result) { 
    document.getElementById("password").value = result.password; 
}); 
関連する問題