Ionic-异步功能在Android上不起作用

时间:2018-09-11 02:28:19

标签: android asynchronous ionic-framework

我有以下代码调用和API,并使用响应中的数据来生成已计算并显示给用户的表。

该功能在我的开发环境上正常工作。但是,当我部署到Android设备上时,没有任何显示

loadActivities(){
this.storage.get('token').then((data) => {
  //console.log('https://kizame-karate.herokuapp.com/' + 'user-activities/' + data);
  this.http.get('https://kizame-karate.herokuapp.com/' + 'user-activities/' + data).subscribe((answer) =>{
    this.tecnico = answer.json()[0].minutos;
    this.anaerobico = answer.json()[1].minutos;
    this.aerobico = answer.json()[2].minutos;
    this.alongamento = answer.json()[3].minutos;
    this.loadTables();  
  },
(error)=> {
  console.log(error);
  this.loadTables(); 
})
});

loadTables() {
this.user_extraActivities = [
  {
    extraActivity_id: 1,
    user_id: 1,
    duration_partial: this.tecnico,
  },
  {
    extraActivity_id: 2,
    user_id: 1,
    duration_partial: this.anaerobico,
  },
  {
    extraActivity_id: 3,
    user_id: 1,
    duration_partial: this.aerobico,
  },
  {
    extraActivity_id: 4,
    user_id: 1,
    duration_partial: this.alongamento,
  }
];

0 个答案:

没有答案