基于uniapp和vue.js实现折叠面板?

基于uniapp和vue.js实现折叠面板?
html:

<template>
	<view class="course">
		<view class="fold-list" v-for="(item,index) in list" :key="index">
			<view class="fold-title">
				<view class="badge">{{item.number}}</view>
				<text>{{item.title}}</text>
				<view class="arrow-icon" @click="changeContent(index);layOut(index)">
				<image v-if="item.lay_type" class="up-arrow" :src="item.imgUrl"></image>
				<image v-else class="up-arrow" :src="item.imgUrl2"></image>
				</view>
			</view>
			<view class="fold-content" v-show="item.showContent" v-for="(itemMsg,indexMsg) in item.msg" :key="indexMsg" @click="changeContentInfo(index,indexMsg)">
				
				{{itemMsg.content}}
			</view>
		</view>
	</view>
</template>

js:

<script>
	export default {
		data() {
			return {

				list: [{
						number: '1',
						title: '基本信息',
						msg: [{
							content: '1'
						}, {
							content: '2'
						}, {
							content: '3'
						}, {
							content: '4'
						}],
						imgUrl: '../../static/imges/recommendFirstTrial/up-arrow.svg',
						imgUrl2: '../../static/imges/recommendFirstTrial/up-arrow2.svg',
						showContent: true,
						lay_type: 1
					},
					{
						number: '2',
						title: '推荐人及行政信息',
						msg: [{
							content: '1'
						}, {
							content: '2'
						}, {
							content: '3'
						}, {
							content: '4'
						}],
						imgUrl: '../../static/imges/recommendFirstTrial/up-arrow.svg',
						imgUrl2: '../../static/imges/recommendFirstTrial/up-arrow2.svg',
						showContent: true,
						lay_type: 1
					},
					{
						number: '3',
						title: '工作经历',
						msg: [{
							content: '1'
						}, {
							content: '2'
						}, {
							content: '3'
						}, {
							content: '4'
						}],
						imgUrl: '../../static/imges/recommendFirstTrial/up-arrow.svg',
						imgUrl2: '../../static/imges/recommendFirstTrial/up-arrow2.svg',
						showContent: true,
						lay_type: 1

					},
					{
						number: '4',
						title: '教育经历',
						msg: [{
							content: '1'
						}, {
							content: '2'
						}, {
							content: '3'
						}, {
							content: '4'
						}],
						imgUrl: '../../static/imges/recommendFirstTrial/up-arrow.svg',
						imgUrl2: '../../static/imges/recommendFirstTrial/up-arrow2.svg',
						showContent: true,
						lay_type: 1

					},
					{
						number: '5',
						title: '项目经验',
						msg: [{
							content: '1'
						}, {
							content: '2'
						}, {
							content: '3'
						}, {
							content: '4'
						}],
						imgUrl: '../../static/imges/recommendFirstTrial/up-arrow.svg',
						imgUrl2: '../../static/imges/recommendFirstTrial/up-arrow2.svg',
						showContent: true,
						lay_type: 1
					},
					{
						number: '6',
						title: '资格证书',
						msg: [{
							content: '1'
						}, {
							content: '2'
						}, {
							content: '3'
						}, {
							content: '4'
						}],
						imgUrl: '../../static/imges/recommendFirstTrial/up-arrow.svg',
						imgUrl2: '../../static/imges/recommendFirstTrial/up-arrow2.svg',
						showContent: true,
						lay_type: 1
					},
					{
						number: '7',
						title: '初审意见',
						msg: [{
							content: '1'
						}, {
							content: '2'
						}, {
							content: '3'
						}, {
							content: '4'
						}],
						imgUrl: '../../static/imges/recommendFirstTrial/up-arrow.svg',
						imgUrl2: '../../static/imges/recommendFirstTrial/up-arrow2.svg',
						showContent: true,
						lay_type: 1
					},
				]
			}
		},
		methods: {
			changeContent(index) { //通过index拿到当前值
				this.list[index].showContent = !this.list[index].showContent;
			},
			changeContentInfo(index, indexMsg) {
				console.log(index, indexMsg)
			},
			layOut(index) {
				if (this.list[index].lay_type == 0) {
					this.list[index].lay_type = 1
				} else {
					this.list[index].lay_type = 0
				}
			}
		}
	}
</script>

css:

<style>
	.fold-title {
		display: flex;
		flex-direction: row;
	}

	.up-arrow {
		width: 36rpx;
		height: 36rpx;
		position: absolute;
		right: 33rpx;
	}

	.badge {
		width: 36rpx;
		height: 36rpx;
		background-color: #FF7A45;
		border-radius: 8rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		align-content: center;
		color: #FFFFFF;
		margin-right: 16rpx;
		padding: 5rpx;
	}
	.arrow-icon{
		display: flex;
		flex-direction: row;
		align-items: center;
		align-content: center;
	}
</style>

效果截图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值