0
我使用XMLHttpRequest將文件發送到後端,並將返回json格式信息,我如何獲取每個值?Angular2讀取json使用XMLHttpRequest.response
代碼
this.resdata = xhr.response;
console.log("this.resdata2: " + this.resdata);
console.log("this.resdata[0]: " + this.resdata[0]);
console.log("this.resdata[1]: " + this.resdata[1]);
和Chrome DevTools消息
this.resdata2: {"result":123,"gpsvalue":246}
home.component.ts:112 this.resdata[0]: {
home.component.ts:113 this.resdata[1]: "
我如何獲得resdata2結果和gpsvalue的價值,並顯示我的網頁上?
節目屬性「gpsvalue」不會對類型「數字」和屬性「結果」存在不上型存在'數'? – KenChen
謝謝你的幫助,問題解決了 – KenChen