uniapp列表实现方式 v-for

创建列表视图 v-for

v-for="对象item in 数组"

v-for="(对象item,下标) in 数组"

v-for="(对象item,使用这个键取到的值,下标) in 数组"

:key 绑定标识 一般建议使用对象中的id等值 类型 any

html 复制代码
<template>
	<view>
		<view class="line" v-for="item in list" :key="item.title" @click="itemClick(key)">
			<image class="imageStype" src="../../static/logo.png"></image>
			<text class="textHellow">{{item.title}}</text>
		</view>
		<view class="line" v-for="(item,i) in list" :key="i" @click="itemClick(key)">
			<image class="imageStype" src="../../static/logo.png"></image>
			<text class="textHellow">{{item.title}}</text>
		</view>
		<view class="line" v-for="(item,title,i) in list" :key="i" @click="itemClick(key)">
			<image class="imageStype" src="../../static/logo.png"></image>
			<text class="textHellow">{{title}}</text>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				list: [{
					title: 0
				}, {
					title: 1
				}, {
					title: 2
				}]

			}
		},
		methods: {
			itemClick(ii) {
				// setInterval(() => {
				// 	Array.from(this.list).forEach((item)=>{
				// 		item.title +=1 
				// 	})
				// }, 2000)
				setTimeout(() => {
					Array.from(this.list).forEach((item) => {
						item.title += 1
					})
				}, 2000)
			}
		},
		beforeDestroy() {

		}
	}
</script>

<style>
	.imageStype {
		width: 120rpx;
		height: 120rpx;
		margin-left: 40rpx;

	}

	.line {
		margin-top: 20rpx;
		display: flex;
		flex-direction: row;
		padding-top: 40rpx;
		padding-bottom: 40rpx;
		width: 670rpx;
		margin-left: 40rpx;
		border: 2rpx solid gray;
		border-radius: 16rpx;
		background-color: aliceblue;
		box-shadow: 8rpx 8rpx 4rpx 0 gray;
	}

	.textHellow {
		margin-left: 20rpx;
		font-weight: bold;
		font-size: 32rpx;
	}
</style>
		
相关推荐
Dreamcatcher_AC21 小时前
慢慢买项目:一站式开发指南
前端·javascript·mongodb·node.js
两个蝴蝶飞21 小时前
Java量化系列(九):实现股票列表自动同步,精准监控新增、更名与退市动态
java·开发语言
独自破碎E21 小时前
Java对象是怎么在虚拟机中存储的?
java·开发语言
西西学代码21 小时前
Flutter---折线图(使用外部库)
前端·javascript·flutter
坚持学习前端日记21 小时前
Android JS桥技术深度解析
android·开发语言·javascript
兮动人21 小时前
打破 OS 壁垒:Java 跨平台硬件信息采集的“终极方案”
java·开发语言
一路往蓝-Anbo21 小时前
STM32单线串口通讯实战(一):物理层拓扑与STM32G0硬件配置
c语言·开发语言·stm32·单片机·嵌入式硬件·物联网
weixin_3077791321 小时前
MATLAB动态演示流体扩散仿真模拟的简单例子
开发语言·matlab
json{shen:"jing"}21 小时前
07_表单输入绑定
java·前端·javascript
yyt3630458411 天前
K 线图高性能窗口化渲染
前端·javascript·css·vue.js·gitee·vue