微信小程序,基于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>
相关推荐
不爱说话郭德纲3 小时前
uni-app x iOS 离线打包踩坑总结
uni-app·xcode
人还是要有梦想的8 小时前
如何开发微信小程序
微信小程序·小程序·notepad++
pengles8 小时前
基于RuoYi-Vue-Plus项目实现移动端项目
java·vue.js·uni-app
inksci1 天前
Js生成安全随机数
前端·微信小程序
azhou的代码园1 天前
基于SpringBoot+微信小程序的图片识别科普系统
spring boot·后端·微信小程序
万岳科技系统开发1 天前
外卖系统选型与源码与 SaaS 实践的思考
数据库·小程序
志遥1 天前
我把 Sentry 接进了 7 端小程序:从异常捕获、Breadcrumb 到 Source Map 定位
微信小程序·监控
云起SAAS1 天前
在线客服系统源码 | 支持PC管理端+H5访客端+实时聊天
微信小程序·ai编程·看广告变现轻·在线客服系统源码
bug总结1 天前
小程序云函数 vs 传统前后端分离(阿里云)原理解析
阿里云·小程序·云计算
2501_933907211 天前
如何通过上海本凡科技获得优质的小程序开发服务?
科技·微信小程序·小程序