组件库文档 tmui.design
轮播 Carousel
该组件一般用于导航轮播,广告展示等场景,可开箱即用。
🌶️ 轮播 Carousel 示例效果
查看模拟效果+
示例代码
vue
<template>
<tm-app>
<tm-sheet>
<tm-text :font-size="24" _class="font-weight-b" label="更多指示点位置,属性等请看文档"></tm-text>
</tm-sheet>
<tm-carousel autoplay :margin="[0,16]" :round="3" :width="686" :height="300" :list="listimg"></tm-carousel>
<tm-sheet>
<tm-text :font-size="24" _class="font-weight-b" label="指示点对齐"></tm-text>
</tm-sheet>
<tm-carousel autoplay :margin="[0,16]" align="right" :round="3" :width="686" :height="300" :list="listimg"></tm-carousel>
<tm-sheet>
<tm-text :font-size="24" _class="font-weight-b" label="指示位置,包含视频播放"></tm-text>
</tm-sheet>
<tm-carousel rangKey="test" autoplay :margin="[0,16]" dotPosition="right" vertical model="rect" :round="3" :width="686" :height="300" :list="listvedio"></tm-carousel>
</tm-app>
</template>
<script lang="ts" setup>
import { ref,Ref } from "vue"
import { onShow, onLoad } from "@dcloudio/uni-app";
import tmApp from "@/tmui/components/tm-app/tm-app.vue"
import tmSheet from "@/tmui/components/tm-sheet/tm-sheet.vue"
import tmText from "@/tmui/components/tm-text/tm-text.vue"
import tmCarousel from "@/tmui/components/tm-carousel/tm-carousel.vue"
import tmDivider from "@/tmui/components/tm-divider/tm-divider.vue"
const listimg = [
"https://picsum.photos/200/300?id=43335",
"https://picsum.photos/200/300?id=433",
"https://picsum.photos/200/300?id=439",
"https://picsum.photos/200/300?id=459",
]
const listvedio:Ref<any[]> = ref([{test:"https://picsum.photos/200/300?id=43335"}, {
test: "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4",
img: "https://picsum.photos/200/300?id=43335",
type: "video"
},
"https://picsum.photos/200/300?id=433"
])
</script>
🌶️ 兼容性
APP-VUE | APP-NVUE | 小程序 | WEB/H5 | VUE3/TS |
---|---|---|---|---|
✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
🌱 参数
本组件含有公共属性 公共属性
参数名 | 类型 | 默认值 | 描述 |
---|---|---|---|
followTheme | Boolean | true | |
color | String | primary | 指示点的主题色 |
width | Number | 750 | 宽度,单位rpx |
height | Number | 500 | 高度,单位rpx |
round | Number | 0 | 开启圆角,单位n*4rpx(即round-1 为 4rpx) |
margin | Array | [0,0] | 外间距[x,y]x=左右,y=上下 |
list | Array | [] | 图片列表,可以是string数组或者object数组。 |
rangKey | String | url | 图片列表object数组时,需要提供图片地址的键值。 |
defaultValue | Number | 0 | |
dotPosition | String | bottom | 指示点的位置:top,left,right,bottom |
align | String | center | 内容居对齐,左left,中center,右right,在dotPosition为left,right时,align的left和right表示,上下对齐 |
model | String | number | 指示点的样式:dot,number,rect |
interval | Number | 5000 | 自动切换时间间隔 |
duration | Number | 500 | 滑动动画时长 |
circular | Boolean | true | 是否采用衔接滑动,即播放到末尾后重新回到开头 |
acceleration | Boolean | false | |
disableProgrammaticAnimation | Boolean | false | |
autoplay | Boolean | true | 是否自动切换 |
displayMultipleItems | Number | 1 | |
skipHiddenItemLayout | Boolean | false | |
disableTouch | Boolean | false | |
touchable | Boolean | false | |
indicatorDots | Boolean | true | 是否显示指示点 |
showLoadv3.0.77+ | Boolean | true | 是否显示加载动画 |
🌹 事件
事件名 | 参数 | 返回数据 | 描述 |
---|---|---|---|
change | |||
click | index |
🌽 slot插槽
默认default
🥗 ref方法
无
💏 文档贡献
此页文档由﹎wj潕钶取玳贡献,如果对该框架感兴趣的可以参与我们一同进步!