最终实现效果(深色为占用时间段):

话不多说,上代码:

<template>
	<view>
		<view class="item">
					<view v-for="(item,index) in nums" :key="index" >
						<view>
							{{item}}
						</view>
					</view>
		</view>
		<view style="display: flex;">
			<view v-for="(item,index) in nums" :key="index"
			:style="{width:100/nums.length + '%'}" style="background:#BBDAFF;height:36rpx">
				<view v-for="(deepitem,dindex) in colorDeeps"
				:key="dindex">
					<view v-if="item>= deepitem.start && item <deepitem.end" class="deep">
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				nums: [
					8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
				],
				colorDeeps:[
					{
						start: 12,
						end: 13
					}
				],
			}
		},
		methods: {
		}
	}
</script>

<style lang="less" scoped>
	.item{
		font-size: 33rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
		height: 60rpx;
		line-height: 54rpx;
		color: #999999;
	}
	.deep{
		background:#4278F7;
		height:36rpx;
	}
	
</style>

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐