【发布时间】:2021-12-31 18:01:48
【问题描述】:
我是 vuetify 的新手,对显示表格感到头疼。我搜索了其他人并在我的身上尝试过,但它没有显示......
我可以使用开发工具查看我的数据,但它不会显示在表格上;~;
这是我的代码
Vuetify 表格代码
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 并且它们都没有工作......我的 vue 版本是 2.6.11 我做错了什么???????????????
【问题讨论】:
-
尝试在 v-data-table 元素上使用 "v-if="boards.length"
标签: javascript json vue.js vuetify.js