当前位置: 首页 > news >正文

uniapp中swiper 轮播带左右箭头,点击切换轮播效果demo(整理)

可以点击箭头左右切换-进行轮播
在这里插入图片描述

<template><view class="swiper-container"><swiper class="swiper" :current="currentIndex" :autoplay="true" interval="9000" circular indicator-dots@change="handleSwiperChange"><block v-for="(item, index) in swiperList" :key="index"><swiper-item><!-- 轮播项的内容 --><image class="swiper-image" :src="item.image"></image></swiper-item></block></swiper><view class="arrow arrow-left" @tap="prev"></view><view class="arrow arrow-right" @tap="next"></view></view>
</template><script>export default {data() {return {swiperList: [{image: "http://www.jq22.com/img/cs/500x500-9.png"},{image: "http://www.jq22.com/img/cs/500x500-9.png"},{image: "http://www.jq22.com/img/cs/500x500-9.png"},],currentIndex: 2,};},methods: {handleSwiperChange(event) {const current = event.detail.current;this.currentIndex = current;console.log("当前轮播到第", current, "个索引");},prev() {this.currentIndex = (this.currentIndex - 1 + this.swiperList.length) % this.swiperList.length;},next() {this.currentIndex = (this.currentIndex + 1) % this.swiperList.length;},},};
</script><style>.swiper-container {position: relative;}.swiper {height: 200px;/* 设置轮播的高度 */}.swiper-image {width: 100%;height: 100%;}.arrow {position: absolute;top: 50%;transform: translateY(-50%);width: 30px;height: 30px;background-color: #000;opacity: 0.6;border-radius: 50%;}.arrow-left {left: 10px;}.arrow-right {right: 10px;}
</style>
http://www.lryc.cn/news/237962.html

相关文章:

  • 网络连接Android设备
  • Redis(位图Bitmap和位域Bitfield)
  • 【ArcGIS】批量对栅格图像按要素掩膜提取
  • 二进制安装minio 并实现主从同步
  • React中封装echarts图表组件以及自适应窗口变化
  • 鸿蒙:使用Stack、ContentTable、Flex等组件和布局实现一个显示界面
  • 3.生成验证码 + 开发登录、退出功能 + 显示登录信息
  • 基于龙格-库塔算法优化概率神经网络PNN的分类预测 - 附代码
  • 2022最新版-李宏毅机器学习深度学习课程-P51 BERT的各种变体
  • JavaFX中Application、Stage、Scene和Parent的区别
  • ubuntu18.04 terminal打不开的解决方法
  • 部署Kubernetes Dashboard
  • Java对List的操作
  • git 将本地已有的一个项目上传到新建的git仓库的方法
  • 基于Docker的安装和配置Canal
  • 去除IDEA中代码的波浪线(黄色警示线)
  • 【Qt之QSplashScreen】开场动画使用:进度条加载及设置鼠标指针不转圈
  • WPF Button点击鼠标左键弹出菜单
  • http库requests
  • package.json 依赖版本中的符号含义
  • Python try except 用法
  • 代码随想录二刷 | 链表 | 翻转链表
  • 每日一题(LeetCode)----链表--两两交换链表中的节点
  • 竞赛选题 身份证识别系统 - 图像识别 深度学习
  • 什么时候用@MapperScan 注解?
  • MQTT.js
  • html滑动文章标题置顶
  • Android11 桌面默认横屏导致任务键近期任务布局UI显示错误!
  • 「Verilog学习笔记」根据状态转移图实现时序电路
  • 使用DHorse发布SpringBoot项目到K8S