微信小程序,基于uni-app的轮播图制作,调用文件中图片

以便捷为目的,想使用文件中的图片制作轮播图

但网上找到的都是轮播图彼此分割,没有使用数组存储在一起,不便于管理,代码不美观简洁

作者使用文件中的图片,并使用数组制作轮播图的具体操作如下:(任一页面的.vue文件,完整简洁代码)

bash 复制代码
<template>
	<swiper>
		<swiper-item v-for = "item in picture" :key="item.id">
			<view>
				<image :src = "item.img"></image>
			</view>
		</swiper-item>
	</swiper>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello uni',
				
				//轮播图数据
				picture : [
					{ id: '1', img: "/static/tabs/home_default.png"},
					{ id: '2', img: "/static/tabs/home_selected.png"}
				]
			}

		},
		onLoad() {

		},
		methods: {

		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
相关推荐
爱学习 爱分享18 小时前
微信小程序html 在 webview 会打开再缩放一下
微信小程序·小程序·html
梦梦代码精19 小时前
深度拆解:上门按摩系统如何成为本地生活“到家时代”的新引擎?
docker·小程序·uni-app·开源·生活·开源软件
Geek_Vison21 小时前
如何借助小程序容器技术实现跨端APP的敏捷开发
小程序·apache·敏捷流程
xshirleyl21 小时前
微信小程序开发week6-慕尚花坊项目
微信小程序·小程序
usdoc文档预览21 小时前
国产化踩坑:Vue3 / React / 小程序如何免插件实现 OFD 及复杂 Office 文档同屏预览
前端·javascript·react.js·小程序·pdf·word·office文件在线预览
倒流时光三十年21 小时前
第二章 小程序目录结构与核心文件详解
spring boot·小程序
好赞科技1 天前
2026年八大上门服务预约小程序:解锁高效生活新体验
大数据·微信小程序
维双云1 天前
从零到一:一份关于“做小程序的步骤”的完整实操指南
小程序
编程猪猪侠1 天前
uni-app微信小程序车牌号输入组件实现
微信小程序·uni-app
h_65432101 天前
uniapp的app/h5实现地图连续定位
uni-app