响应式,移动友好,支持触摸的列表滚动器,可像轮播一样滚动浏览帖子,文章,图像和报价。
2020年7月22日
2020/07/02
# Yarn
$ yarn add vue-horizontal-list
# NPM
$ npm install vue-horizontal-list --save
1.导入vue-horizontal-list组件。
import Vue from 'vue';
import VueHorizontalList from '@/vue-horizontal-list.vue';
2.将组件添加到应用模板。
<vue-horizontal-list :items="items" :options="options">
<template v-slot:default="{item}">
<div class="item">
<h5>{{item.title}}</h5>
<p>{{item.content}}</p>
</div>
</template>
</vue-horizontal-list>
3.在应用程序上呈现vue-horizontal-list。
export default Vue.extend({
name: 'Name',
components: {
VueHorizontalList
},
data() {
return {
options: {
// options here
},
items: [
{title: 'Item 0', content: 'Content item with description'},
]
}
}
});
4.默认props
/**
* items to display in horizontal-list
*/
items: {
type: Array,
required: true
},
/**
* item.class = css class for each individual item
* item.padding = padding between each item in the list
*
* list.class = css class for the parent of item
* list.windowed = maximum width of the list it can extend to, basically the container max-width
* list.padding = padding of the list, if container < windowed what is the left-right padding of the list
*
* responsive breakpoints to calculate how many items to show in the list at each width interval
* Examples:
* [{size: 5}] show 5 items regardless
* [{end: 992, size: 3}},{size: 4}] < 992 show 3 items, else show 4 items
* [{end: 576, size: 1}, {start: 576, end: 992, size: 2}, {size: 3}] < 576 show 1, 576 - 992 show 2, else show 3
*
* These are the default responsive fallback, if you don't have a catch all, it will fallback to this.
* [{end: 576, size: 1},
* {start: 576, end: 768, size: 2},
* {start: 768, end: 992, size: 3},
* {start: 992, end: 1200, size: 4},
* {start: 1200, size: 5}]
*/
options: {
type: Object,
required: false
}