vue 列表滑动_滑动式卡带传送带,可通过Vue查看列表

Vue卡轮播组件用于实现列表滑动查看,提供全局和局部安装方式,支持自定义道具和插槽进行高度定制。组件仍处于积极开发阶段,内容可能会在alpha版本后发生变化。
摘要由CSDN通过智能技术生成

vue 列表滑动

Vue卡轮播 (Vue Card Carousel)

Sliding card carousel for list viewing.

滑动卡传送带,可用于查看列表。

*Please note this is in active development and subject to change until it is out of alpha versions.

*请注意,这是在积极的开发中,并且可能会有所更改,直到超出alpha版本为止。

安装 (Installation)

npm i vue-card-carousel

You can choose to install either globally or locally:

您可以选择在全局或本地安装:

Globally:

全球范围内:

import Vue from 'vue'
import App from './App.vue'
import VueCardCarousel from "vue-card-carousel";

Vue.use(VueCardCarousel)

new Vue({
  el: '#app',
  render: h => h(App)
})

or locally to a component:

或局部于组件:

import { VueCardCarousel } from "vue-card-carousel";

export default {
    components: {
        VueCardCarousel
    }
}

用法 (Usage)

Most basic usage would be adding the component and passing in the array of items you want displayed. Note you will need to set the minimum height of the component, otherwise it won't display. The width will take up 100% by default. These can be easily configured via CSS.

最基本的用法是添加组件并传入要显示的项目数组。 请注意,您将需要设置组件的最小高度,否则它将不会显示。 默认情况下,宽度将占100%。 这些可以通过CSS轻松配置。

<template>
  <div id="app">
    <VueCardCarousel class="vcc" :items="listOfTodos" />
  </div>
</template>

<script>
import { VueCardCarousel } from "vue-card-carousel";

export default {
  components: {
    VueCardCarousel
  },
  data() {
    return {
      listOfTodos: [{ id: 1 }, { id: 2 }, { id: 3 }]
    };
  }
};
</script>

<style scoped>
  .vcc {
    height: 50vh;
    width: 60vw;
  }
</style>

However this will be relatively uninteresting. To make the most use of this component, you'll want to add customizations via props and slots like below:

但是,这将相对没有意思。 为了充分利用此组件,您需要通过以下道具和插槽添加自定义项:

<template>
  <div id="app">
    <VueCardCarousel
      class="vcc"
      :items="listOfTodos"
      :header-options="headerOpt"
      :footer-options="footerOpt"
    >
      <template v-slot:header="slotProps">
        <strong>Header. Id: {{ slotProps.headerProp.id }}</strong>
      </template>
      <template v-slot:default="slotProps">
        <div v-for="n in 5" :key="n">
          {{ slotProps.bodyProp.cMainId }}. Hello from the Parent.
        </div>
      </template>
      <template v-slot:footer="slotProps">
        <strong>Footer. Id: {{ slotProps.footerProp.id }}</strong>
      </template>
    </VueCardCarousel>
  </div>
</template>

<script>
import { VueCardCarousel } from "vue-card-carousel";

export default {
  components: {
    VueCardCarousel
  },
  data() {
    return {
      listOfTodos: [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }],
      headerOpt: { isVisible: true, backgroundColor: "green" },
      footerOpt: { isVisible: false }
    };
  }
};
</script>

<style scoped>
  .vcc {
    height: 50vh;
    width: 60vw;
  }
</style>

道具 (Props)

PropertyTypeDefaultRequiredDescription
itemsArraytrueList of items to used to generate the scrollable cards.
startIndexNumber0falseIndex of the card you want to be centered on first. Removes trailing digits if found.
hideBackdropBooleanfalsetrueShows/hides the backdrop. Akin to a modal backdrop.
sideCardOpacityNumber0.25falseSets the minimum opacity for the cards on either side of the center card.
headerOptionsObjectfalseSee details below for available properties.
footerOptionsObjectfalseSee details below for available properties.
属性 类型 默认 需要 描述
items 数组 真正 用于生成可滚动卡的项目列表。
startIndex 0 您要首先居中的卡的索引。 删除尾随的数字(如果找到)。
hideBackdrop 布尔型 真正 显示/隐藏背景。 类似于模态背景。
sideCardOpacity 0.25 设置中心卡两侧的卡的最小不透明度。
headerOptions 目的 有关可用属性,请参见下面的详细信息。
footerOptions 目的 有关可用属性,请参见下面的详细信息。

headerOptions (headerOptions)

PropertyTypeDefaultRequiredDescription
isVisibleBooleantrueControls whether or not the header is displayed.
backgroundColorStringfalseAny valid CSS color.
属性 类型 默认 需要 描述
isVisible 布尔型 真正 控制是否显示标题。
backgroundColor 任何有效CSS颜色。

footerOptions (footerOptions)

PropertyTypeDefaultRequiredDescription
isVisibleBooleantrueControls whether or not the footer is displayed.
backgroundColorStringfalseAny valid CSS color.
属性 类型 默认 需要 描述
isVisible 布尔型 真正 控制是否显示页脚。
backgroundColor 任何有效CSS颜色。

插槽 (Slots)

Scoped slots are exposed for each sub-section of the card: header, body, and footer. Each slot has slot props which give access to the individual item from the list that was passed in through the items property, so you can use that data to fully customize the card.

卡的每个子部分都暴露了适用的插槽:页眉,正文和页脚。 每个插槽都有插槽道具,通过这些道具可以访问通过items属性传递的列表中的单个项目,因此您可以使用该数据完全自定义卡。

NameDescriptionScope
headerIndividual item from the list passed in through the items prop.headerProp
defaultIndividual item from the list passed in through the items prop.bodyProp
footerIndividual item from the list passed in through the items prop.footerProp
名称 描述 范围
header 列表中的单个项目通过items属性传递。 headerProp
default 列表中的单个项目通过items属性传递。 bodyProp
footer 列表中的单个项目通过items属性传递。 footerProp

In the above example, we have named the object containing all our slot props slotProps, but you can choose to call this anything. More info can be found here: https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots

在上面的示例中,我们已命名包含所有插槽道具slotProps的对象,但是您可以选择将其命名为任何对象。 可以在此处找到更多信息: https : //vuejs.org/v2/guide/components-slots.html#Scoped-Slots

翻译自: https://vuejsexamples.com/sliding-card-carousel-for-list-viewing-with-vue/

vue 列表滑动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值