uniapp循环

文章描述:

uniapp循环数组和字符串循环

template

<template>
    <view>
	<view v-for="(item,index) in list" :key="index" @click="item(index)">
	    {{item}}-{{index}}
	</view>
    </view>
</template>

script

export default {
    data(){
	return{
		list:[
		    1,2,3,4,5,6,7,8,9,10,11,12
		]
	}
    },
    methods: {
	item:function(e){
		console.log(e);
	}
    }
}

字符分割循环

template

<template>
    <view>
	<view v-for="(item,index) in list">
	    <view>{{item.title}}</view>
	    <view v-for="(data,index) in item.annexs.split(',')" :key='index'>
	       {{data}}
	    </view>
	</view>
    </view>
</template>

script

export default {
    data(){
	return{
	    list:[
		{
		   "title":"电脑",
		   "annexs":"1.jpg,2.jpg,3.jpg",
		},
		{
		   "title":"手机",
		   "annexs":"4.jpg,5.jpg",
		},
		]
	}
    },
    methods: {
	item:function(e){
	    console.log(e);
	}
    }
}

 

发布时间:2021/10/09

发表评论