FilterItem.vue 1.26 KB
<template>
	<view class="filter-item">
		<view class="filter-title">
			<text>{{ title }}</text>
		</view>
		<view class="filter-list">
			<view v-for="(item, index) in filterList" :key="index" @click="radioClick(index)" :class="['tag-item', { checked: item.checked, 'mr-30': (index + 1) % 3 !== 0 }]">
				{{ item.name }}
			</view>
		</view>
	</view>
</template>

<script>
export default {
	props: {
		title: {
			type: String,
			default: ''
		},
		filterList: {
			type: Array,
			default: () => []
		}
	},
	methods: {
		radioClick(currentIndex) {
			this.$emit('clickTag', currentIndex);
		}
	}
};
</script>

<style lang="scss" scoped>
.filter-item {
	margin-top: 40rpx;
	.filter-title {
		color: #333;
		font-size: 14px;
		font-weight: 700;
	}
	.filter-list {
		display: flex;
		flex-wrap: wrap;
		.tag-item {
			margin-top: 30rpx;
			width: 210rpx;
			height: 68rpx;
			border-radius: 32rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #333;
			font-size: 13px;
			border: 1px solid #fff;
			background-color: #f6f6f6;
		}
		.checked {
			border: 1px solid #377dff4d;
			background-color: #377dff0d;
			color: #377dffff;
		}
		.mr-30 {
			margin-right: 30rpx;
		}
	}
}
</style>