为什么 b-table 显示我的数据库的所有列,即使我在我的服务器上指定列

Why b-table displays all columns of my database even I specify the columns on my server

为什么我的 b-table 显示我 table 的所有列,即使我只选择了一些?

这是调用所选列的服务器端代码。另外,如果我只使用 bootstrap 而不是 bootstrap-vue.

router.get('/users', function(req, res) {
  /* Get the person who has the latest date  */
  let getUser = "SELECT DISTINCT(MEMB.MEMB_N), MAX(PrintDate) AS PrintDate, MEMB.* \
                       FROM MEMB LEFT JOIN VD_Print ON MEMB.MEMB_N = VD_Print.MEMB_N GROUP BY MEMB.LAST_M \
                       ORDER BY PrintDate DESC LIMIT 100;"
  myDB.query(getUser, function(err, rows) {
    if (err) {
      console.log(err);
    } else {
      console.log(rows);
      res.send(rows);
    }
  });
});

这个在我的客户端是 vuejs

<template>
      <section>
        <div class="sidebar"></div>
        <div>
          <b-form-input class="searchBar" placeholder="Search Here"></b-form-input>
        </div>
        <div>
          <b-table class="table" striped hover :items="results"></b-table>
        </div>
        <b-button class="printBtn">PRINT</b-button>
      </section>
    </template>

<script>
  import axios from "axios";
  export default {
    data() {
      return {
        results: [],
      };
    },
    mounted() {
      this.getUsers();
    },
    methods: {
      getUsers: function() {
        axios
          .get("http://localhost:9000/api/users/")
          .then(response => (this.results = response.data))
          .catch(error => alert(error));
      }
    }
  };
</script>

我的 JSON 看起来像这样:

您需要在 b-table 的字段定义中定义您的列名。如果您多次提交回复,但您希望显示某些字段。

请在下面的代码和工作 demo

代码片段

export default {
  data() {
    return {
      selectAll: false,
      records: [],
      perPage: 10,
      currentPage: 1,
      pageOptions: [5, 10, 15],
      column: [{
        key: "name",
        sortable: true,
        label: "Log File Name"
      }, {
        key: "lastModified",
        sortable: true,
        label: "Last Modified Date",
        class: "text-right options-column"
      }]
    };
  }
}
<template>
    <div>
      <div v-if="!hasRecords" style="text-align: center"><br><br>LOADING DATA...</div>
      <div style="padding: 15px;" v-if="hasRecords">
        <b-table :items="records" :fields="column" striped hover :current-page="currentPage" :per-page="perPage">
        </b-table>
        <b-row>
          <b-col md="6" class="my-1">
              <b-pagination :total-rows="totalRows" :per-page="perPage" v-model="currentPage" class="my-0" />
          </b-col>
          <b-col md="6" class="my-1">
              <b-form-group horizontal label="Per page" class="mb-0">
                  <b-form-select :options="pageOptions" v-model="perPage" />
              </b-form-group>
          </b-col>
        </b-row>
      </div>
    </div>
</template>