【发布时间】:2019-02-21 02:45:51
【问题描述】:
我的 vue 组件是这样的:
<template>
...
<b-col v-for="item in items"
v-bind:key="item.id"
cols="2">
...
<strong slot="header" class="text-dark" :title="item.tittle" >{{item.tittle}}</strong><br/>
...
<strong class="bg-warning text-dark"><i class="fa fa-money"></i> <b>{{item.price}}</b></strong><br/>
...
</b-col>
...
<b-pagination size="sm" :total-rows="itemsPagination.total" :per-page="itemsPagination.per_page" v-model="itemsPagination.current_page" prev-text="Prev" next-text="Next" hide-goto-end-buttons/>
...
</template>
<script>
export default {
...
data () {
return{
items: '',
itemsPagination: ''
}
},
mounted: function () {
this.getItems()
},
methods: {
getItems() {
let params = []
...
let request = new Request(ApiUrls.items + '?' + params.join('&'), {
method: 'GET',
headers: new Headers({
'Authorization': 'bearer ' + this.$session.get(SessionKeys.ApiTokens),
'Content-Type': 'text/plain'
})
})
fetch(request).then(r=> r.json())
.then(r=> {
this.items = r.data
this.itemsPagination = r
})
.catch(e=>console.log(e))
}
}
}
</script>
如果我console.log(this.itemsPagination),控制台中的结果如下:
我的应用程序中的分页视图如下:
如果脚本执行,它会在第1页显示项目的内容。但是如果我点击第2页等,项目的内容不会改变。我仍然很困惑如何让它运作良好
我该如何解决这个问题?
更新
我用的是coreui
https://coreui.io/vue/demo/#/base/paginations
https://github.com/coreui/coreui-free-vue-admin-template/blob/master/src/views/base/Paginations.vue
【问题讨论】:
-
你能提供
b-pagination的代码+按next或2时的网络响应是什么 -
@Frank Provost 我使用 coreui。看看这个:coreui.io/vue/demo/#/base/paginations 和 github.com/coreui/coreui-free-vue-admin-template/blob/master/…。好像是自动的
标签: javascript vue.js pagination vuejs2 vue-component