【发布时间】:2020-04-23 15:22:14
【问题描述】:
你好朋友,我如何使用 javascript 从数据响应中访问数据索引。这是我的代码: HTML
<label id="user">USER</label>
这里是javascript
this.$store.dispatch('Login',this.value_login)
.then(response => {
if(response!='') {
this.login_result = new Array();
this.login_result = response;
document.getElementById('user').innerHTML= this.login_result.firstname
}
});
这是我从响应中得到的数据
感谢您的帮助
【问题讨论】:
-
数据索引是什么意思?您还可以分享您对该电话的回复吗?注意
this.login_result = new Array();是多余的,因为它被以下内容覆盖:this.login_result = response; -
好的,我已经编辑了我的问题并将数据图片添加到我的问题中
-
复制粘贴数据而不是图像会更好(下次) - 但也感谢您。
-
看到您的响应的 pass 和 word 之间的回车(换行符)字符了吗?这会破坏 json
-
好的,这是复制过去:[{"id":1,"firstname":"Neng","lastname":"vang","email":"nengvang@gmail.com", "密码":"1234"}]
标签: javascript html css node.js vue.js