drop-down.vue 1.8 KB
<template>
	<view class="drop-down-list" v-if="isShow" :style="{  top: top + 'px' }">
		<view class="san-jiao"></view>
		<block v-for="(item,index) in selectList" :key="index">
			<view class="city-items-names" @click="changeIm(item.deptname)" :class="item.isactive?'ac-tive':''">
				{{item.deptname}}
			</view>
		</block>
	</view>
</template>
<script>
	export default {
		props: {
			show: {
				type: Boolean,
				default: false,
			},
			list: {
				type: Array,
				default () {
					return []
				}
			},
			active: {
				type: String,
				default: '',
			},
			top: {
				type: String,
				default: '40',
			}
		},
		data() {
			return {
				isShow: this.show,
				selectList: this.list,
				isActive: this.active,

			}
		},
		created() {

		},
		mounted() {

		},
		watch: {
			list(val, oldval) {
				this.selectList = val
			},
			show(val, oldval) {
				this.isShow = val
			},
			active(val, oldval) {
				this.isActive = val
			},
		},
		computed: {

		},
		components: {

		},
		methods: {
			changeIm(im) {
				console.log(im, );
				this.$emit('changedItem', im)
			}
		},
	}
</script>
<style scoped lang="scss">
	.drop-down-list {
		width: 100%;
		position: absolute;
		top: 40px;
		left: 0;
		z-index: 2;
		border-radius: 6px;
		opacity: 1;
		background: #fff;
		box-shadow: -2px 3px 11px 0px rgba(58, 63, 71, 0.08);


		.san-jiao {
			border-width: 10px;
			border-style: solid;
			border-radius: 6px;
			border-color: transparent transparent #fff transparent;
			position: absolute;
			top: -16px;
			right: 30%;
			z-index: 2;
		}

		.city-items-names {
			width: 100%;
			text-align: center;
			line-height: 50px;
			border-bottom: 1px solid #F2F5FA;
			color: #000;

		}

		.ac-tive {
			color: #5397FF;
		}
	}
</style>
<style>


</style>