【发布时间】:2020-04-23 01:25:46
【问题描述】:
我正在尝试在 vue 中实现分页。我在这里面临的问题是分页链接显示为点,如附图所示。出现的分页链接数是正确的。我可以使用分页链接 () 上的侧导航箭头在不同的页面上导航。我无法弄清楚我哪里出错了。帮我弄清楚这个问题。
<template>
<v-app class="abilities">
<v-data-table
:headers="headers"
:items="users"
hide-actions
class="user-table"
v-bind:pagination.sync="pagination"
>
<template slot="items" slot-scope="props">
<td>{{ props.item.date }}</td>
<td>{{ props.item.description }}</td>
</template>
<template slot="no-data" >
<v-alert id='no-data' :value="true" color="error" icon="warning">
No User Yet
</v-alert>
</template>
</v-data-table>
<v-layout row wrap v-if="this.users.length > 5">
<v-flex xs12>
<div class="user-pagination">
<v-pagination v-model="pagination.page" :length="pages"></v-pagination>
</div>
</v-flex>
</v-layout>
</v-app>
</template>
<script>
export default {
data: function() {
return {
pagination: {
rowsPerPage: 5,
page: 1
},
headers: [
{
text: 'Date',
sortable: false,
value: 'name'
},
{
text: 'Description',
sortable: false,
value: 'name'
},
],
users: [],
};
},
created: function() {
var that = this;
this.fetchUsers();
},
computed: {
pages () {
return this.pagination.rowsPerPage ? Math.ceil(this.users.length / this.pagination.rowsPerPage) : 0
}
},
methods: {
fetchUsers() {
var url = '/users.json?';
this.$axios
.get(url)
.then(response => {
let data = response.data;
let users = [];
data.map((user, index) => {
let expandedData = user;
users.push(expandedData)
});
this.users = users;
});
}
}
};
</script>
【问题讨论】:
-
如果您使用浏览器 F12
Inspect,那么 DOM 中的...值是否显示为数字或相同的...?这似乎是ellipsis文本大小写(可能在服务器或前端) -
此问题已在更改浏览器大小时得到修复。知道如何解决这个问题吗?
-
我认为这很可能是 Vuetify 的噱头:“使用 length 属性可以设置 v-pagination 的长度,如果页面按钮的数量超过父容器,就会截断列表。” vuetifyjs.com/en/components/paginations
-
我已经在使用 length 属性了。
标签: javascript vue.js pagination vuetify.js