适用于Vue的移动友好列表滚动器–vue-horizontal-list

适用于Vue的移动友好列表滚动器–vue-horizontal-list

插件名称:vue-horizontal-list

发布时间:2020年5月15日

插件作者:fuxingloh

官网 演示 GitHub下载

响应式,移动友好,支持触摸的列表滚动器,可像轮播一样滚动浏览帖子,文章,图像和报价。

变更日志:

2020年7月22日

  • v1.0.12:使用babel空合并功能修复了错误的整数零问题

2020/07/02

  • v1.0.11

安装与使用:

# Yarn
$ yarn add vue-horizontal-list
# NPM
$ npm install vue-horizontal-list --save

如何使用它:

1.导入vue-horizo​​ntal-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-horizo​​ntal-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
}
相关插件