Vuetify table 未显示数据

Vuetify table not showing data

我是 vuetify 的新手,对显示 table 感到头疼。我搜索了其他人并在我的身上试过了,但没有显示...

shows data on dev tool

我可以使用开发工具查看我的数据,但它不会显示在 table ;~;

这是我的代码

Vuetify Table 代码

BoardList.vue

<template>
  <v-container>
    <v-data-table
      :headers="headers"
      :items="boards"
      class="elevation-1"
      :search="search"
    >
      <template v-slot:item="props">
        <td class="text-xs-right">{{ props.item.articleno }}</td>
        <td class="text-xs-right">{{ props.item.data.articleno }}</td>
      </template>
    </v-data-table>
    <v-col><v-col md="8" /></v-col>
    <v-container>
      <v-row>
        <v-col md="6" />
        <v-btn @click="goodbye"> 게시글 삭제</v-btn>
      </v-row>
    </v-container>
  </v-container>
</template>

脚本部分

<script>
import { listArticle } from "@/api/board";
export default {
  name: "MemberList",
  methods: {
    goodbye() {
      alert("remove?");
    },
  },
  data() {
    return {
      search: "",
      headers: [
        {
          text: "article number",
          align: "start",
          sortable: true,
          value: "articleno",
        },
        { text: "Subject", value: "subject" },
      ],
      boards: [],
    };
  },
  created() {
    listArticle(
      (response) => {
        this.boards = response.data;
      },
      (error) => {
        console.log(error);
      }
    );
  },
};
</script>

api/board.js

function listArticle(param, success, fail) {
  api.get(`/board`, { params: param }).then(success).catch(fail);
}

我尝试了 props.item.articleno、props.item.data.articleno、item.articleno、item.data.articleno 和 none 它们都可以工作...我的 vue 版本是 2.6。 11 我做错了什么

我可能错了,但看起来你在调用 listArticle 方法时只传递了两个项目。

如何定义:listArticle(param, success, fail)

如何称呼:listArticle((response) => {}, (error) => {});

应该如何称呼:listArticle(param, (response) => {}, (error) => {});

response.data 中的项目是否有 props.item.data.articleno 中使用的 data 道具?我猜 data 不存在,所以无法找到密钥 articleno 并且浏览器访问嵌套值时出错,导致插槽无法显示。

其他建议(可能无法解决):

  • 将两个 <td> 包裹在 <tr> 中(除非它已经是物品槽模板的一部分,如果你有任何行显示,请检查 DOM)
  • 解构 v-slot 道具,这样您就不必将其引用为 props.item
<template v-slot:item="{ item }">
  <tr>
    <td class="text-xs-right">{{ item.articleno }}</td> // this should work
    <td class="text-xs-right">{{ item.data.articleno }}</td> // i don't think this will
  </tr>
</template>