public_switching.vue 1.2 KB
<template>
	<view class="public_switching" :style="{'grid-template-columns': `repeat(${option.length}, 1fr)`}">
		<view 
			@click="selected(item)"
			:class="{'public_switching-i': true, 'public_switching-i-c': item.value === current} " 
			v-for="item in option" 
			:key="item.value">{{ item.lable }}</view>
	</view>
</template>

<script>
	export default {
		name:"public_switching",
		props: {
			current: {
				type: [String, Number],
				default: ''
			},
			option: {
				type: [Array],
				default: () => []
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			selected(item) {
				this.$emit('change', item.value)
			}
		}
	}
</script>

<style lang="scss" scoped>
.public_switching{
	display: flex;
	background-color: #fff;
	border-top: 1rpx solid #f3f4f6;
	.public_switching-i{
		font-size: 28rpx;
		color: #323232;
		width: 50%;
		height: 88rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.public_switching-i-c{
		color: #2D81FF;
		position: relative;
		&:before{
			content: '';
			position: absolute;
			bottom: 0;
			left: 50%;
			background-image: url(@/static/imagesV2/icon23.png);
			background-size: 100% 100%;
			transform: translateX(-50%);
			height: 24rpx;
			width: 24rpx;
		}
	}
}
</style>