-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed : b-pagination not working with v-for, only works with b-table #2133
Comments
Whenever you use |
@tmorehouse yeah i did it here is my code <div v-for="list in lists" :key="list.id">
{{ list.name }}
</div>
<b-pagination
:total-rows="totalRows"
v-model="currentPage"
:per-page="5"
/>
data () {
return {
currentPage: 1
}
},
computed: {
lists () {
return this.$store.getters.loadedLists
},
totalRows () {
return this.$store.getters.loadedLists.length
}
} |
Ah, the <template>
<div v-for="list in lists" :key="list.id">
{{ list.name }}
</div>
<b-pagination
:total-rows="totalRows"
v-model="currentPage"
:per-page="perPage"
/>
</template>
<script>
export default {
data () {
return {
currentPage: 1,
perPage: 5,
}
},
computed: {
lists () {
const items = this.$store.getters.loadedLists
// Return just page of items needed
return items.slice(
(this.currentPage - 1) * this.perPage,
this.currentPage * this.perPage
)
},
totalRows () {
return this.$store.getters.loadedLists.length
}
}
}
</script> |
@tmorehouse Thank you very much i just forgot to use some logics and i did it with <template>
<div id="lists">
<div v-for="list in lists" :key="list.id">
{{ list.name }}
</div>
</div>
<b-pagination-nav :link-gen="linkGen" :number-of-pages="numPages" v-model="currentPage" />
</template>
<script>
export default {
data () {
return {
currentPage: 1,
perPage: 2
}
},
computed: {
lists () {
const items = this.$store.getters.loadedLists
// Return just page of items needed
return items.slice(
(this.currentPage - 1) * this.perPage,
this.currentPage * this.perPage
)
},
numPages () {
return Math.ceil(this.$store.getters.loadedLists.length / this.perPage)
}
},
methods: {
linkGen (pageNum) {
return '#page=' + pageNum
}
}
}
</script> |
If you are using vue-router, then for your return { path: '#page=' + pageNum } Which is a router route object Or set |
b-pagination
orb-pagination-nav
not working with v-for only works withb-table
please give a example
b-pagination
orb-pagination-nav
works with<div v-for="item in items>
The text was updated successfully, but these errors were encountered: