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

微信小程序,基于uni-app的轮播图制作,轮播图本地文件图片预览

完整代码

<template><swiper class="banner" indicator-dots circular :autoplay="false"><swiper-item v-for = "item in picture" :key="item.id"><view><image @tap="onPreviewImage(item.img)" :src = "item.img"></image></view></swiper-item></swiper>
</template><script>export default {data() {return {//轮播图数据picture : [{ id: '1', img: "/static/tabs/home_default.png"},{ id: '2', img: "/static/tabs/home_selected.png"}]}},onLoad() {},methods: {onPreviewImage(img){// console.log(url)wx.previewImage({urls: this.picture.map(item=>item.img),current: img})}}}
</script><style>.banner,.banner image{width: 750rpx;height: 750rpx;}
</style>

关键代码

  • 绑定点击时间,并传送img地址
<image @tap="onPreviewImage(item.img)" :src = "item.img"></image>
  • 设置图片预览
		methods: {onPreviewImage(img){// console.log(url)wx.previewImage({urls: this.picture.map(item=>item.img),current: img})}}
http://www.xdnf.cn/news/152587.html

相关文章:

  • 4.26学习——web刷题
  • 头歌实训之存储过程、函数与触发器
  • leetcode 283和2460
  • 【运维】云端掌控:用Python和Boto3实现AWS资源自动化管理
  • react 报错
  • 路由交换网络专题 | 第八章 | GVRP配置 | 端口安全 | 端口隔离 | Mux-VLAN | Hybrid
  • SinSR模型剪枝实验报告
  • 【LeetCode 热题 100】链表 系列
  • WPF实现数字孪生示例
  • linux socket编程之tcp(实现客户端和服务端消息的发送和接收)
  • 北斗导航 | 基于Transformer+LSTM+激光雷达的接收机自主完好性监测算法研究
  • Ext JS模拟后端数据之SimManager
  • 模型识别能力锤炼及清单
  • 8.学习笔记-Maven进阶(P82-P89)
  • AI数字人:未来职业的重塑(9/10)
  • 【高频考点精讲】第三方库安全审计:如何避免引入带漏洞的npm包
  • springboot入门-service层构造器注入原理
  • 推荐系统FM模型
  • 2025.4.26_STM32_SPI
  • 29、简要描述三层架构开发模式以及三层架构有哪些好处?
  • Vue3中AbortController取消请求的用法详解
  • Log4j Properties 配置项详细说明
  • 如何判断你的PyTorch是GPU版还是CPU版?
  • 4.23-4.26学习总结 HTML—CSS常见标签和样式
  • 实验四 进程调度实验
  • Adriuno:编程语言基础
  • 使用 Truffle 和 Ganache 搭建本地以太坊开发环境并部署一个简单智能合约
  • [mysql]约束(上)
  • 使用 Frida 绕过 iOS 应用程序中的越狱检测
  • 自动化测试实战篇