<template>
	<view class="skeleton-box">
		<view v-if="loading" class="skeleton">
			<text>数据加载中...</text>
			<!-- <view class="led" :style="{'--i':index,'--all':25}" v-for="(item,index) in 25" :key='index' /> -->
		</view>
		<van-transition v-else-if="list.length==0" name="fade-up">
			<view class="skeleton">
				暂时没有数据
			</view>
		</van-transition>
		<van-transition v-else name="fade-up">
			<slot></slot>
		</van-transition>
	</view>
</template>

<script>
	export default {
		props: {
			loading: {
				type: Boolean,
				default: true
			},
			list: {
				type: Array,
				default: [1]
			}
		}
	}
</script>

<style lang="scss" scoped>
	.skeleton {
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 50rpx;
		height: 320rpx;
	}

	.led {
		width: 10rpx;
		height: 30rpx;
		border-radius: 10rpx;
		top: 50rpx;
		position: absolute;
		transform: rotate(calc(360deg / var(--all) * var(--i)));
		transform-origin: 0 160rpx;
		animation: loading 2s linear infinite;
		animation-delay: calc(var(--i) * 1s);
		background-color: green;
	}

	@keyframes loading {
		from {
			opacity: 0;
		}

		to {
			opacity: 1;
		}
	}
</style>
