0.0.4 • Published 4 years ago

pb-vue-carousel v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

轮播组件

基于Vue的通用轮播组件,需搭配pb-vue-carousel-item使用,目前提供淡入、平移两种切换方式

安装

npm i pb-vue-carousel
或
yarn add pb-vue-carousel

基本使用

可通过Vue.use()全局注册

import Vue from 'vue'
import PbCarousel from 'pb-vue-carousel'
import PbCarouselItem from 'pb-vue-carousel-item'

Vue.use(PbCarousel)
Vue.use(PbCarouselItem)

也可在组件中局部引用

<template>
	<div class="app">
        <pb-carousel>
    		<pb-carousel-item v-for="item in 3" :key="item">
    			<div style="background: green;color: white">
                    {{ item }}
    			</div>
    		</pb-carousel-item>
    	</pb-carousel>
    </div>
</template>

<script>
import PbCarousel from 'pb-vue-carousel'
import PbCarouselItem from 'pb-vue-carousel-item'
export default {
    components: {
        PbCarousel,
        PbCarouselItem
    }
}
</script>

自定义指示器样式

<template>
  <div id="app">
    <carousel
      type="fade"
      height="300px"
      :custom-indicator-style="{
        width: '20px',
        height: '5px',
        background: 'yellow'
      }"
      :custom-indicator-active-style="{
        width: '10px',
        height: '10px',
        borderRadius: '50%',
        background: 'red'
      }"
    >
      <carousel-item
        v-for="item in 5"
        :key="item"
      >
        <div>
          {{ item }}
        </div>
      </carousel-item>
    </carousel>
  </div>
</template>

自定义切换按钮样式

<template>
  <div id="app">
    <carousel
      type="fade"
      height="300px"
      :custom-prev-button-style="{
        imageUrl: '../arrow-left.png',
        style: {
          width: '24px',
          height: '24px'
        }
      }"
      :custom-next-button-style="{
        imageUrl: '../arrow-right.png',
        style: {
          width: '24px',
          height: '24px'
        }
      }"
    >
      <carousel-item
        v-for="item in 5"
        :key="item"
      >
        <div>
          {{ item }}
        </div>
      </carousel-item>
    </carousel>
  </div>
</template>

Attributes

参数说明类型可选值默认值
interval轮播的切换时长number3000
height轮播容器的高度string150px
type轮播切换的类型stringfade/movefade
show-indicator是否展示指示器booleantrue
show-switch-button是否展示切换按钮booleantrue
custom-prev-button自定义向前切换的按钮样式只接受固定属性的object{imageUrl: string, style: object}
custom-next-button自定义向后切换的按钮样式只接受固定属性的object{imageUrl: string, style: object}
custom-indicator-style自定义指示器样式object
custom-indicator-active-style自定义激活状态的指示器样式object
0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago