New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue-carousel-card

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-carousel-card

vue轮播卡片组件(vue carousel card component)with vue@3.x

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

npm package

❗ vue轮播卡片组件(vue carousel card component),2.x版本为vue@3.x组件

❗ 如需在vue@2.x中使用,请使用 vue-carousel-card@1.0.7,Github v1.x地址 github 1.x
yarn add vue-carousel-card@^1.0.7
npm i vue-carousel-card@^1.0.7 -S

示例

demo展示

vue-carousel-card vue-carousel-card

用法

# 安装依赖
yarn add vue-carousel-card
# or
npm i vue-carousel-card -S

引入依赖,SPA,非SSR

// 样式需要单独引入
import { defineComponent } from 'vue'
import { CarouselCard, CarouselCardItem } from 'vue-carousel-card'
import 'vue-carousel-card/styles/index.css'

export default defineComponent({
  // 注册组件
  components: { CarouselCard, CarouselCardItem }
})

// 全局引入
import CarouselCard from 'vue-carousel-card'
import 'vue-carousel-card/styles/index.css'

const app = createApp(App)
app.use(CarouselCard)
app.mount('#app')

引入依赖,服务端渲染(SSR)中使用,以Nuxtjs为例

// TODO
// 后期测试后再进行补充
<!-- 使用组件 -->
<template>
  <CarouselCard ref="carouselCardRef" :interval="7000" :autoplay="false" height="260px" type="card" arrow="always" @change="changeHandle">
    <CarouselCardItem v-for="i in 6" :key="i" :name="`cc_${i}`">
      <h1 v-text="i"></h1>
    </CarouselCardItem>
  </CarouselCard>
  <div style="text-align: center; padding: 10px">
    <button @click="prev">prev</button>
    <button @click="next">next</button>
    <button @click="setToFirst">set to first</button>
  </div>
  <CarouselCard :interval="3000" height="300px" :autoplay="false" arrow="always" direction="vertical">
    <CarouselCardItem v-for="i in 6" :key="i">
      <h1 v-text="i"></h1>
    </CarouselCardItem>
  </CarouselCard>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue'
import { ICarouselCard } from 'vue-carousel-card'

export default defineComponent({
  setup () {
    const carouselCardRef = ref<ICarouselCard>()
    const changeHandle = (index: number) => {
      console.log(index)
    }
    const next = () => {
      carouselCardRef.value?.next()
    }
    const prev = () => {
      carouselCardRef.value?.prev()
    }
    const setToFirst = () => {
      carouselCardRef.value?.setActiveItem(0)
    }
    return {
      carouselCardRef,
      changeHandle,
      next,
      prev,
      setToFirst
    }
  }
})
</script>
/* 示例样式 */
h1 {
  height: 100%;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #FFF;
  background: linear-gradient(90deg, rgba(88,140,236,1), rgba(106,106,207,1))
}

参数

CarouselCard Attributes
参数说明类型可选值默认值
height走马灯的高度string
initial-index初始状态激活的幻灯片的索引,从 0 开始number0
trigger指示器的触发方式stringclick
autoplay是否自动切换booleantrue
interval自动切换的时间间隔,单位为毫秒number3000
indicator-position指示器的位置stringoutside/none
arrow切换箭头的显示时机stringalways/hover/neverhover
type走马灯的类型stringcard
loop是否循环显示boolean-true
direction展示的方向booleanhorizontal/verticalhorizontal
pause-on-hover鼠标悬浮时暂停自动切换boolean-true
CarouselCard Events
事件名称说明回调参数
change幻灯片切换时触发目前激活的幻灯片的索引,原幻灯片的索引
CarouselCard Methods
方法名说明参数
setActiveItem手动切换幻灯片需要切换的幻灯片的索引,从 0 开始;或相应 carousel-card-item 的 name 属性值
prev切换至上一张幻灯片
next切换至下一张幻灯片
CarouselCardItem Attributes
参数说明类型可选值默认值
name幻灯片的名字,可用作 setActiveItem 的参数string
label该幻灯片所对应指示器的文本string

Keywords

FAQs

Package last updated on 23 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc