我无法将来自index.html的表单数据保存在chrome本地存储中。我也尝试将数据保存在chrome同步存储中,但两者均无法正常工作,并且已经在chrome:// extensions中检查了我的本地存储,但是没有数据。...我应该怎么做才能将数据保存在chrome扩展存储中?
manifest.json
{
"manifest_version": 2,
"name": "index",
"version": "1.0.0",
"description": "index descript",
"icons": {
"512": "img/logo.png"
},
"browser_action": {
"default_icon": {
"16": "img/logo.png"
},
"default_popup": "index.html",
"default_title": "index",
"use_navigation_bar": false,
"mobile_user_agent": true
},
"background": {
"scripts": [ "js/background.js" ]
},
"permissions": ["tabs", "notifications", "storage"]
}
(function(){
var form = document.querySelector('form');
form.addEventListener('submit', function(evt){
evt.preventDefault();
runStorage();
})
})()
function runStorage() {
var country = $("#selectCur").val(),
krw = $("#wantKRW").val(),
date = $("#pdate").val(),
arr = [country, krw, date];
chrome.storage.local.get(['data'], function(res) {
if(res.data) {
res.data.push(arr);
var a = res.data;
chrome.storage.local.set({ data : a}, function() {
});
}
});
}