uniapp tab同步组件及引入

uniapp yekong 932℃

uniapp tab同步组件

使用

		<div class="list2">
			<div class="listTitle">
				赠品
			</div>
			<div class="listTab">
				<tabblock :active.sync="active" :list="statuslist"></tabblock>
			</div>
		</div>

js

<script>
	import tabblock from '@/components/tab/tab_block_sync.vue'
	export default {
		components: {
			tabblock
		},
		data() {
			return {
				active: '0',
				statuslist: [{
					name: '葱',
					id: '0'
				}, {
					name: '姜',
					id: '1'
				}, {
					name: '蒜',
					id: '2'
				}],
			}
		},
	}
</script>

组件代码

<template>
	<div class="tabs">
		<div class="tab cur" :class="{active:active==item.id}" @click="getactive(item.id)" v-for="(item,index) in list"
			:key="index"><span>{{ item.name }}</span>
		</div>
	</div>
</template>
<script>
	export default {
		name: "tabs",
		components: {},
		props: {
			list: {
				type: Array,
				default () {
					return [];
				}
			},
			active: {
				type: Number | String,
				default () {
					return 0;
				}
			},
		},
		data() {
			return {

			}
		},
		watch: {},
		mounted() {},
		methods: {
			getactive(e) {
				this.$emit('update:active', e)
			},
		}
	}
</script>
<style scoped lang="scss">
	.tabs {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: nowrap;
		flex-direction: row;
		margin: auto;

		.tab {
			border-radius: 10px;
			display: flex;
			width: 185rpx;
			height: 58rpx;
			font-family: PingFangSC-Regular;
			font-size: 28rpx;
			color: #555555;
			text-align: center;
			font-weight: 400;
			border: 1rpx solid #aaaaaa;
			box-sizing: border-box;
			border-radius: 10rpx;
			justify-content: center;
			align-items: center;
			flex-wrap: nowrap;
			flex-direction: row;
			align-content: flex-start;
			margin-right: 37rpx;

			span {
				font-size: 28rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: rgba(33, 33, 33, 1.00);
				padding: 0 24rpx;
			}

		}

		.tab.active {
			width: 185rpx;
			height: 58rpx;
			background: #FF9349;
			border: 1rpx solid rgba(0, 0, 0, 0);

			span {
				color: #fff;
			}
		}

		.tab:nth-child(3n) {
			margin-right: 0;
		}
	}
</style>

喜欢 (0)