//保存数据
function save(){
var contact = new Object;
contact.user_name = document.getElementById("user_name").value;
contact.mobilephone = document.getElementById("mobilephone").value;
contact.company = document.getElementById("company").value;
var str = JSON.stringify(contact);
localStorage.setItem(contact.mobilephone,str);
loadAll();
}
//查找数据
function find(){
var search_phone = document.getElementById("search_phone").value;
var name = localStorage.getItem(search_phone);
var mobilephone = localStorage.key(name);
var str = localStorage.getItem(contact.mobilephone);
var contact = JSON.parse(str);
var find_result = document.getElementById("find_result");
find_result.innerHTML = search_phone + "的机主是:" +contact.user_name;
}
在查询数据的代码中想要通过JSON.parse()来获取准确的储存在本地上的值,但是那里错误呢?
千巷猫影
蓝山帝景
慕姐8265434
相关分类