vue没有显示正确的信息

时间:2019-12-04 18:32:57

标签: vue.js

因此,我正在为我的gta v服务器工作于一台hud,而我使用vue。一切工作都完美,只有一件事没有获得正确的价值。打开hud时,它将显示Helper未定义,我不知道为什么,因为使用与帮助程序相同的代码,我可以获得有关管理员的正确信息。

这是我用来显示值的代码:

<div class="mb-4" v-if="getClass('helpers').length > 0">
          <div class="page-subtitle">
            <div class="value">{{getClass('helpers').length}}</div>
            <div class="text">Helpers</div>
          </div>
          <div v-for="(x, index) in getClass('helpers')" v-bind:key="index" class="online-entry">
            <div class="text">
              {{x.name}} ({{x.id}}) 
              <span v-if="x.helper != 0" class="badge bg-warning text-dark small rounded p-2 ml-2">{{x.helper == 1337 ? 'Helpers Leader' : 'Helper ' + x.helper}}</span>
            </div>
            <div class="value">
              {{x.ping}}
              <i class="fas fa-signal ml-1" :style="x.ping > 50 ? 'color: red' : 'color: green'"></i>
            </div>
          </div>
        </div>

这是getClass函数:

getClass: function(clasa) {
    if(clasa == 'civillians') {
      let arrayPlayers = [];
      this.modalData.players.forEach((player, index) => {
        if(player.admin != 0) return;
        if(player.helper != 0) return;
        if(player.leader != 0) return;
        if(player.member != 0) return;
        if(player.premium != 0) return;
        arrayPlayers.push(player);
      });
      return arrayPlayers;
    }
    if(clasa == 'admins') {
      let arrayPlayers = [];
      this.modalData.players.forEach((player, index) => {
        if(player.admin == 0) return;
        arrayPlayers.push(player);
      });
      return arrayPlayers;
    }
    if(clasa == 'helpers') {
      let arrayPlayers = [];
      this.modalData.players.forEach((player, index) => {
        if(player.helper == 0) return;
        arrayPlayers.push(player);
      });
      return arrayPlayers;
    }
    if(clasa == 'premium') {
      let arrayPlayers = [];
      this.modalData.players.forEach((player, index) => {
        if(player.premium == 0) return;
        if(player.admin != 0) return;
        if(player.helper != 0) return;
        arrayPlayers.push(player);
      });
      return arrayPlayers;
    }
  },

1 个答案:

答案 0 :(得分:0)

问题是我写的时候忘记从数据库发送辅助值。