在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  C++  HTML/ Angular4 http post 事件方法中調(diào)用多個(gè)post請(qǐng)求?

Angular4 http post 事件方法中調(diào)用多個(gè)post請(qǐng)求?

Angular4 中,我在事件方法里面寫(xiě)了兩個(gè)http post請(qǐng)求,造成了數(shù)據(jù)混亂,data1和data2的數(shù)據(jù)相同
例如:

html:

<button (click)="getData()">點(diǎn)擊AB按鈕</button>

ts:

import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/map';

public getData () {
        this.http.post(this.heroesUrl1, JSON.stringify(curVal), {headers: this.headers})
            .map( res => {
              return res.json();
            }).subscribe( res => {
            this.data1 = JSON.stringify(res);
        });
        this.http.post(this.heroesUrl2, JSON.stringify(curVal), {headers: this.headers})
            .map( data => {
                return data.json();
            }).subscribe( data => {
            this.data2 = JSON.stringify(data);
        });
}

問(wèn)題: 兩個(gè)post請(qǐng)求返回的數(shù)據(jù)相同,即data1和data2的數(shù)據(jù)相同,這是什么原因造成的,該如何解決

回答
編輯回答
我不懂

你確定你兩個(gè)url返回的不是同一份數(shù)據(jù)?

2017年4月21日 06:37
編輯回答
氕氘氚

檢查下地址是否一致,再檢查下返回的原始數(shù)據(jù)是否相同,在dev tool中Network里去看下。

2017年5月11日 05:51