uni-app 折叠自定义

uni-app的uni-collapse折叠组件样式修改
下面是修改后的样式

<uni-collapse accordion class="ze"  v-model="isCollapse" @click="toggleCollapse">
				<!-- 因为list默认带一条分隔线,所以使用 titleBorder="none" 取消面板的分隔线 -->
					<uni-collapse-item title-border="none" :border="false"
					 class="ze_item"
					 >
						<template v-slot:title>
							<uni-list>
								<uni-list-item title="阅读理解-作者思维知识点"
								 :show-extra-icon="true" :extra-icon="isCollapse ? extraIcon : CloseFold"
								 :show-badge="false"
								 >
								</uni-list-item>
							</uni-list>
						</template>
						<view class="content">
							<uni-list>
								<uni-list-item title="阅读理解-作者思维知识点"
								 :show-extra-icon="true" :extra-icon="{type:'smallcircle-filled',color: '#FF6A28',size: '14'}"
								 :show-badge="false"
								 >
								 <template v-slot:footer>
									<image class="slot-image" src="/static/img/Answerbutton.png" mode="widthFix"></image>
								</template>
								</uni-list-item>
								<uni-list-item title="阅读理解-作者思维知识点"
								 :show-extra-icon="true" :extra-icon="{type:'smallcircle-filled',color: '#FF6A28',size: '14'}"
								 :show-badge="false"
								 >
								</uni-list-item>
								<uni-list-item title="阅读理解-作者思维知识点"
								 :show-extra-icon="true" :extra-icon="{type:'smallcircle-filled',color: '#FF6A28',size: '14'}"
								 :show-badge="false"
								 >
								</uni-list-item>
							</uni-list>
							
						</view>
					</uni-collapse-item>
				<uni-collapse-item title-border="none" title="手风琴效果" class="ze_item"
				thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
				>
						<text>折叠内容</text>
				</uni-collapse-item>
				<uni-collapse-item title-border="none" title="禁用状态" class="ze_item"
				thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
				>
					<text>折叠内容</text>
				</uni-collapse-item>
			</uni-collapse>
// js
return {
			isCollapse: false, // 展开。后续会在循环的时候加入open字段表示当前参数已经展开,这里只							做展示
			extraIcon: {color: '#FF6A28',size: '26',type: 'minus-filled'}, // 展开的icon
			CloseFold:{color: '#FF6A28',size: '26',type: 'plus-filled'} // 关闭的icon
}
methods: {
		toggleCollapse() {
			this.isCollapse = !this.isCollapse;
		},
}

修改的css

// 修改折叠的默认样式 list列表的上下border
	/deep/.uni-collapse,/deep/.uni-list--border:after,/deep/.uni-list--border-top,/deep/.uni-list--border-bottom{
		background-color: transparent;
	}
	// 左侧图标往右便宜
	/deep/.uni-list-item__icon {
		margin-right: 30rpx;
	}
	// 去掉父元素往左偏移
	/deep/.uni-list-item__container {
		padding-left: 0px;
	}
	.content{
		// 展开子元素往左偏移
		/deep/.uni-list-item__container {
			padding-left: 7.5px;
		}
	}
	// 手动添加的图标
	.slot-image,/deep/.slot-image{
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		// margin-right: 10px;
		width: 28rpx;
		height: 28rpx;
	}
	// 去掉原生的折叠的图标
	/deep/.custom_none{
		display: none;
	}
	// 去掉原生的图标旋转
	/deep/.custom_uni-collapse-item__title-arrow-active{
		    transform: rotate(0deg);
	}

修改一下uni-collapse的uni-collapse-item

<view v-if="showArrow"
				:class="{ 'uni-collapse-item__title-arrow-active': isOpen, 'uni-collapse-item--animation': showAnimation === true }"
				class="uni-collapse-item__title-arrow custom_uni-collapse-item__title-arrow-active">
				<uni-icons class="custom_none" :color="disabled?'#ddd':'#bbb'" size="14" type="bottom" />
				<image class="slot-image" src="/static/img/Answerbutton.png" mode="widthFix"></image>
			</view>

在这里插入图片描述
设计图样式
在这里插入图片描述
修改后的样式
在这里插入图片描述
就这样吧…

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时间轴-小文同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值