前端Vue自定义轮播图swiper 轮播图dot 轮播图指示indicate

前端Vue自定义轮播图swiper 轮播图dot 轮播图指示indicate,下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=13193

效果图如下:

编辑切换为居中

添加图片注释,不超过 140 字(可选)

编辑切换为居中

添加图片注释,不超过 140 字(可选)

编辑切换为居中

添加图片注释,不超过 140 字(可选)

#### 使用方法

```使用方法

<!-- swiperList:轮播数组 imgField: 轮播图片字段 @click: 轮播图条目点击-->

<cc-dotSwiper :swiperList="bannerList" imgField="imgSrc" @click="swiperItemClick"></cc-dotSwiper>

```

#### HTML代码实现部分

```html

<template>

<view class="content">

<!-- swiperList:轮播数组 imgField: 轮播图片字段 @click: 轮播图条目点击-->

<cc-dotSwiper :swiperList="bannerList" imgField="imgSrc" @click="swiperItemClick"></cc-dotSwiper>

</view>

</template>

<script>

export default {

data() {

return {

bannerList: [{"imgSrc":"https://cdn.pixabay.com/photo/2016/07/18/04/19/canton-1525284_1280.jpg"},

{"imgSrc":"https://cdn.pixabay.com/photo/2022/04/27/12/30/switzerland-7160290_1280.jpg"},

{"imgSrc":"https://cdn.pixabay.com/photo/2017/09/05/17/28/guangzhou-2718517_1280.jpg"}

]

}

},

methods: {

swiperItemClick(item) {

console.log('点击轮播图条目 = ' + item);

uni.showModal({

title:'点击轮播图条目',

content:'点击轮播图条目 = ' + JSON.stringify(item)

})

}

}

}

</script>

<style>

.content {

display: flex;

flex-direction: column;

background-color: aliceblue;

height: 100vh;

}

</style>

</style>

```

#### 组件实现代码

```组件实现代码

<template>

<view class="swiper-box">

<swiper class="swiper" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="500"

:circular="true" @change="change">

<swiper-item v-for="(item,index) in swiperList" :key="index">

<view class="swiper-item" @click="swiperItemClick(item)">

<image class="swiper-item" :src="item[imgField]" mode=""></image>

</view>

</swiper-item>

</swiper>

<!-- dots -->

<view class="dtos">

<view class="dto" :class="{'dto-active':index===currIndex}" v-for="(item,index) in swiperList" :key="index">

</view>

</view>

</view>

</template>

<script>

export default {

props: {

// 轮播图数组

swiperList: {

type: Array,

default: []

},

// 图片字段

imgField: {

type: String,

default: 'imgSrc'

},

},

data() {

return {

currIndex: 0,

};

},

methods: {

change(s) {

this.currIndex = s.detail.current;

},

swiperItemClick(item) {

this.$emit("click", item);

}

}

}

</script>

<style lang="scss" scoped>

.swiper-box {

width: 100%;

height: auto;

background: #fff;

}

.swiper {

margin-left: 3vw;

width: 94vw;

height: 200px;

margin: 25upx auto 0;

}

.swiper-item {

width: 690upx;

height: 200px;

}

.dtos {

display: flex;

justify-content: center;

margin-top: 22upx;

height: 16px;

.dto {

width: 14upx;

height: 14upx;

border-radius: 500upx;

background: #e5e5e5;

margin: 0 7upx;

transition: width 0.5s;

}

.dto-active {

// background: #c2c2c2;

background: orangered;

width: 26upx;

}

}

</style>

```


http://www.niftyadmin.cn/n/1009384.html

相关文章

chat gpt网页版

ChatGPT&#xff1a;开启智能对话的未来 在当今数字化的世界中&#xff0c;人工智能技术正日益成为我们生活中不可或缺的一部分。而在人工智能技术的众多应用中&#xff0c;自然语言处理&#xff08;NLP&#xff09;技术的发展尤为引人注目。在这个领域中&#xff0c;ChatGPT作…

1. Except

文章目录 Except前言Except 语法Except 使用举例结合其他关键字使用EXCEPT with BETWEEN operatorExcept with IN operatorEXCEPT with LIKE operator 文章参考 Except 前言 SQL中&#xff0c;EXCEPT 操作用于检索存在于第一个表中的唯一记录&#xff0c;而不是两个表中共有的…

【Linux基础及shell脚本】磁盘管理(二)

文章目录 1. 磁盘空间的管理1.1 磁盘空间查询1.1.1 df命令1.1.2 du命令 1.2 磁盘配额1.3 文件与目录的查找 2. RAID与LVM2.1 RAID简介2.1.1 RAID级别2.1.2 Linux下的RAID管理 2.2 LVM简介2.2.1 LVM的优点2.2.2 LVM的管理 3. 磁盘备份与恢复3.1 备份工具3.1.1 dd命令3.1.2 tar命…

MySQL数据库第一课 ---------安装

作者前言 欢迎小可爱们前来借鉴我的gtiee秦老大大 (qin-laoda) - Gitee.com 目录 虚拟环境虚拟环境 安装虚拟机 自主安装 简易安装 ———————————————————————————————————————— 虚拟环境虚拟环境 我们现在运行代码的环境是在 PyCharm…

C++中functional函数和bind的用法

1、函数指针例证&#xff1a; int fun(int x, int y) { //被调用的函数std::cout << x << "" << y << std::endl;return x y; }int fun1(int (*fp)(int, int), int x, int y) { //形参为函数指针return fp(x, y…

C++primer(第五版)第七章(类)

类的基本思想是数据抽象和封装. 数据抽象是一种依赖于接口和实现的分离的编程技术. 封装实现了类的接口和实现的分离. 7.1定义抽象数据类型 定义一个抽象数据类型使用关键字struct或是clas(差别仅在于默认访问权限修饰符). //这是一个简单的类定义 class Student{ …

【Mysql】MySQL体系结构,InnoDB、MyISAM存储引擎,索引结构、分类、语法、性能分析

1. MySQL体系结构 连接层 主要完成一些类似于连接处理、授权认证、及相关的安全方案。在该层上引入了线程池的概念&#xff0c;为通过认证安全接入的客户端提供线程。同样在该层上可以实现基于SSL的安全链接。服务器也会为安全接入的每个客户端验证它所具有的操作权限。 服务层…

使用阿里云实现短信验证码

首先去阿里云中开启短信服务 然后申请自己的签名&#xff0c;发送的短信模板&#xff0c;之后点击右上角的头像&#xff0c;点击AccessKey&#xff0c;选第一个就行&#xff0c;然后保存这两个对应的值。 在等待签名和发送模板通过审核之后就可以配置我们的发送方法&#xff0c…