2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-19 09:50:33 +03:00

feat: header, footer, list-header, list-footer slots (#1085)

This commit is contained in:
Jeff Sagal
2020-03-09 21:56:37 -07:00
committed by GitHub
parent 3c546346f7
commit b2f388bc89
6 changed files with 193 additions and 1 deletions
+49
View File
@@ -0,0 +1,49 @@
<template>
<v-select :options="paginated" @search="query => search = query" filterable="false">
<li slot="list-footer" class="pagination">
<button @click="offset -= 10" :disabled="!hasPrevPage">Prev</button>
<button @click="offset += 10" :disabled="!hasNextPage">Next</button>
</li>
</v-select>
</template>
<script>
import countries from '../data/countries';
export default {
data: () => ({
countries,
search: '',
offset: 0,
limit: 10,
}),
computed: {
filtered () {
return this.countries.filter(country => country.includes(this.search));
},
paginated () {
return this.filtered.slice(this.offset, this.limit + this.offset);
},
hasNextPage () {
const nextOffset = this.offset + 10;
return Boolean(this.filtered.slice(nextOffset, this.limit + nextOffset).length);
},
hasPrevPage () {
const prevOffset = this.offset - 10;
return Boolean(this.filtered.slice(prevOffset, this.limit + prevOffset).length);
}
},
};
</script>
<style scoped>
.pagination {
display: flex;
margin: .25rem .25rem 0;
}
.pagination button {
flex-grow: 1;
}
.pagination button:hover {
cursor: pointer;
}
</style>
+1
View File
@@ -119,6 +119,7 @@ module.exports = {
children: [
['guide/validation', 'Validation'],
['guide/selectable', 'Limiting Selections'],
['guide/pagination', 'Pagination'],
['guide/vuex', 'Vuex'],
['guide/ajax', 'AJAX'],
['guide/loops', 'Using in Loops'],