vue 中 json.parse没有被定义怎么回事
答案:2 悬赏:60 手机版
解决时间 2021-03-17 19:53
- 提问者网友:寂寞梧桐
- 2021-03-16 19:18
vue 中 json.parse没有被定义怎么回事
最佳答案
- 五星知识达人网友:鸠书
- 2021-03-16 20:56
contact对象没有定义,localStorage.key方法乱用
你的数据结构里头mobilephone===search_phone,不然localStorage取出来的是null哇,要判断一下的
1
2
3
4
5
6
7
function find(){
var str=localStorage[document.getElementById("search_phone").value];
if(str){
var contact=JSON.parse(str);
document.getElementById("find_result").innerHTML=contact.mobilephone+"的机主是:" +contact.user_name;
}
}
你的数据结构里头mobilephone===search_phone,不然localStorage取出来的是null哇,要判断一下的
1
2
3
4
5
6
7
function find(){
var str=localStorage[document.getElementById("search_phone").value];
if(str){
var contact=JSON.parse(str);
document.getElementById("find_result").innerHTML=contact.mobilephone+"的机主是:" +contact.user_name;
}
}
全部回答
- 1楼网友:不想翻身的咸鱼
- 2021-03-16 21:48
contact对象没有定义,localstorage.key方法乱用
你的数据结构里头mobilephone===search_phone,不然localstorage取出来的是null哇,要判断一下的
function find(){
var str=localstorage[document.getelementbyid("search_phone").value];
if(str){
var contact=json.parse(str);
document.getelementbyid("find_result").innerhtml=contact.mobilephone+"的机主是:" +contact.user_name;
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯